18bf80f4bSopenharmony_ci/* 28bf80f4bSopenharmony_ci * Copyright (C) 2024 Huawei Device Co., Ltd. 38bf80f4bSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 48bf80f4bSopenharmony_ci * you may not use this file except in compliance with the License. 58bf80f4bSopenharmony_ci * You may obtain a copy of the License at 68bf80f4bSopenharmony_ci * 78bf80f4bSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 88bf80f4bSopenharmony_ci * 98bf80f4bSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 108bf80f4bSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 118bf80f4bSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 128bf80f4bSopenharmony_ci * See the License for the specific language governing permissions and 138bf80f4bSopenharmony_ci * limitations under the License. 148bf80f4bSopenharmony_ci */ 158bf80f4bSopenharmony_ci 168bf80f4bSopenharmony_ci#ifndef OHOS_RENDER_3D_LIGHT_JS_H 178bf80f4bSopenharmony_ci#define OHOS_RENDER_3D_LIGHT_JS_H 188bf80f4bSopenharmony_ci#include <meta/interface/intf_object.h> 198bf80f4bSopenharmony_ci 208bf80f4bSopenharmony_ci#include "BaseObjectJS.h" 218bf80f4bSopenharmony_ci#include "ColorProxy.h" 228bf80f4bSopenharmony_ci#include "NodeJS.h" 238bf80f4bSopenharmony_ci 248bf80f4bSopenharmony_ciclass BaseLight : public NodeImpl { 258bf80f4bSopenharmony_cipublic: 268bf80f4bSopenharmony_ci static constexpr uint32_t ID = 10; 278bf80f4bSopenharmony_ci enum LightType { 288bf80f4bSopenharmony_ci /** 298bf80f4bSopenharmony_ci * Directional light. 308bf80f4bSopenharmony_ci */ 318bf80f4bSopenharmony_ci DIRECTIONAL = 1, 328bf80f4bSopenharmony_ci /** 338bf80f4bSopenharmony_ci * Spotlight. 348bf80f4bSopenharmony_ci */ 358bf80f4bSopenharmony_ci SPOT = 2, 368bf80f4bSopenharmony_ci /** 378bf80f4bSopenharmony_ci * Point light. 388bf80f4bSopenharmony_ci */ 398bf80f4bSopenharmony_ci POINT = 3, 408bf80f4bSopenharmony_ci }; 418bf80f4bSopenharmony_ci static void Init(const char* name, napi_env env, napi_value exports, 428bf80f4bSopenharmony_ci BASE_NS::vector<napi_property_descriptor>& node_props, napi_callback ctor); 438bf80f4bSopenharmony_ci BaseLight(LightType lt); 448bf80f4bSopenharmony_ci ~BaseLight() override; 458bf80f4bSopenharmony_ci static void RegisterEnums(NapiApi::Object exports); 468bf80f4bSopenharmony_ci 478bf80f4bSopenharmony_ciprotected: 488bf80f4bSopenharmony_ci void Create(napi_env e, napi_callback_info i); 498bf80f4bSopenharmony_ci void* GetInstanceImpl(uint32_t id); 508bf80f4bSopenharmony_ci void DisposeNative(TrueRootObject*); 518bf80f4bSopenharmony_ci void Finalize(napi_env env, TrueRootObject*); 528bf80f4bSopenharmony_ci 538bf80f4bSopenharmony_ciprivate: 548bf80f4bSopenharmony_ci napi_value GetlightType(NapiApi::FunctionContext<>& ctx); 558bf80f4bSopenharmony_ci napi_value GetEnabled(NapiApi::FunctionContext<>& ctx); 568bf80f4bSopenharmony_ci void SetEnabled(NapiApi::FunctionContext<bool>& ctx); 578bf80f4bSopenharmony_ci 588bf80f4bSopenharmony_ci napi_value GetColor(NapiApi::FunctionContext<>& ctx); 598bf80f4bSopenharmony_ci void SetColor(NapiApi::FunctionContext<NapiApi::Object>& ctx); 608bf80f4bSopenharmony_ci 618bf80f4bSopenharmony_ci napi_value GetShadowEnabled(NapiApi::FunctionContext<>& ctx); 628bf80f4bSopenharmony_ci void SetShadowEnabled(NapiApi::FunctionContext<bool>& ctx); 638bf80f4bSopenharmony_ci 648bf80f4bSopenharmony_ci napi_value GetIntensity(NapiApi::FunctionContext<>& ctx); 658bf80f4bSopenharmony_ci void SetIntensity(NapiApi::FunctionContext<float>& ctx); 668bf80f4bSopenharmony_ci 678bf80f4bSopenharmony_ci LightType lightType_; 688bf80f4bSopenharmony_ci BASE_NS::unique_ptr<ColorProxy> colorProxy_; 698bf80f4bSopenharmony_ci}; 708bf80f4bSopenharmony_ci 718bf80f4bSopenharmony_ciclass SpotLightJS : BaseObject<SpotLightJS>, BaseLight { 728bf80f4bSopenharmony_cipublic: 738bf80f4bSopenharmony_ci static constexpr uint32_t ID = 11; 748bf80f4bSopenharmony_ci static void Init(napi_env env, napi_value exports); 758bf80f4bSopenharmony_ci SpotLightJS(napi_env, napi_callback_info); 768bf80f4bSopenharmony_ci 778bf80f4bSopenharmony_ciprivate: 788bf80f4bSopenharmony_ci void* GetInstanceImpl(uint32_t id); 798bf80f4bSopenharmony_ci void DisposeNative(); 808bf80f4bSopenharmony_ci void Finalize(napi_env env); 818bf80f4bSopenharmony_ci}; 828bf80f4bSopenharmony_ci 838bf80f4bSopenharmony_ciclass DirectionalLightJS : BaseObject<DirectionalLightJS>, BaseLight { 848bf80f4bSopenharmony_cipublic: 858bf80f4bSopenharmony_ci static constexpr uint32_t ID = 12; 868bf80f4bSopenharmony_ci static void Init(napi_env env, napi_value exports); 878bf80f4bSopenharmony_ci DirectionalLightJS(napi_env, napi_callback_info); 888bf80f4bSopenharmony_ci 898bf80f4bSopenharmony_ciprivate: 908bf80f4bSopenharmony_ci void* GetInstanceImpl(uint32_t id); 918bf80f4bSopenharmony_ci void DisposeNative(); 928bf80f4bSopenharmony_ci void Finalize(napi_env env); 938bf80f4bSopenharmony_ci napi_value GetNear(NapiApi::FunctionContext<>& ctx); 948bf80f4bSopenharmony_ci void SetNear(NapiApi::FunctionContext<float>& ctx); 958bf80f4bSopenharmony_ci}; 968bf80f4bSopenharmony_ciclass PointLightJS : BaseObject<PointLightJS>, BaseLight { 978bf80f4bSopenharmony_cipublic: 988bf80f4bSopenharmony_ci static constexpr uint32_t ID = 13; 998bf80f4bSopenharmony_ci static void Init(napi_env env, napi_value exports); 1008bf80f4bSopenharmony_ci PointLightJS(napi_env, napi_callback_info); 1018bf80f4bSopenharmony_ci 1028bf80f4bSopenharmony_ciprivate: 1038bf80f4bSopenharmony_ci void* GetInstanceImpl(uint32_t id); 1048bf80f4bSopenharmony_ci void DisposeNative(); 1058bf80f4bSopenharmony_ci void Finalize(napi_env env); 1068bf80f4bSopenharmony_ci}; 1078bf80f4bSopenharmony_ci 1088bf80f4bSopenharmony_ci#endif // OHOS_RENDER_3D_LIGHT_JS_H 109