• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #ifndef ENVIRONMENTJS_H
16 #define ENVIRONMENTJS_H
17 #include "BaseObjectJS.h"
18 #include "SceneResourceImpl.h"
19 #include "Vec4Proxy.h"
20 class EnvironmentJS : public BaseObject, SceneResourceImpl {
21 public:
22     static constexpr uint32_t ID = 90;
23     static void Init(napi_env env, napi_value exports);
24 
25     EnvironmentJS(napi_env, napi_callback_info);
26     ~EnvironmentJS() override;
27     void* GetInstanceImpl(uint32_t id) override;
28 
29 private:
30     void DisposeNative(void*) override;
31     void Finalize(napi_env env) override;
32     // JS properties
33     enum EnvironmentBackgroundType {
34         /**
35          * The background is none.
36          *
37          * @syscap SystemCapability.ArkUi.Graphics3D
38          * @since 12
39          */
40         BACKGROUND_NONE = 0,
41 
42         /**
43          * The background is image.
44          *
45          * @syscap SystemCapability.ArkUi.Graphics3D
46          * @since 12
47          */
48         BACKGROUND_IMAGE = 1,
49 
50         /**
51          * The background is cubmap.
52          *
53          * @syscap SystemCapability.ArkUi.Graphics3D
54          * @since 12
55          */
56         BACKGROUND_CUBEMAP = 2,
57 
58         /**
59          * The background is equirectangular.
60          *
61          * @syscap SystemCapability.ArkUi.Graphics3D
62          * @since 12
63          */
64         BACKGROUND_EQUIRECTANGULAR = 3,
65     };
66 
67     napi_value GetBackgroundType(NapiApi::FunctionContext<>& ctx);
68     void SetBackgroundType(NapiApi::FunctionContext<uint32_t>& ctx);
69     napi_value GetEnvironmentImage(NapiApi::FunctionContext<>& ctx);
70     void SetEnvironmentImage(NapiApi::FunctionContext<NapiApi::Object>& ctx);
71     napi_value GetRadianceImage(NapiApi::FunctionContext<>& ctx);
72     void SetRadianceImage(NapiApi::FunctionContext<NapiApi::Object>& ctx);
73     napi_value GetIrradianceCoefficients(NapiApi::FunctionContext<>& ctx);
74     void SetIrradianceCoefficients(NapiApi::FunctionContext<NapiApi::Array>& ctx);
75 
76     napi_value GetIndirectDiffuseFactor(NapiApi::FunctionContext<>& ctx);
77     void SetIndirectDiffuseFactor(NapiApi::FunctionContext<NapiApi::Object>& ctx);
78 
79     napi_value GetIndirectSpecularFactor(NapiApi::FunctionContext<>& ctx);
80     void SetIndirectSpecularFactor(NapiApi::FunctionContext<NapiApi::Object>& ctx);
81 
82     napi_value GetEnvironmentMapFactor(NapiApi::FunctionContext<>& ctx);
83     void SetEnvironmentMapFactor(NapiApi::FunctionContext<NapiApi::Object>& ctx);
84     BASE_NS::unique_ptr<Vec4Proxy> diffuseFactor_;
85     BASE_NS::unique_ptr<Vec4Proxy> specularFactor_;
86     BASE_NS::unique_ptr<Vec4Proxy> environmentFactor_;
87 };
88 #endif
89