/*
* Copyright (C) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "GeometryJS.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include "MeshResourceJS.h"
#include "ParamParsing.h"
#include "SceneJS.h"
#include "geometry_definition/GeometryDefinition.h"
void* GeometryJS::GetInstanceImpl(uint32_t id)
{
if (id == GeometryJS::ID)
return this;
return NodeImpl::GetInstanceImpl(id);
}
void GeometryJS::DisposeNative(void* scn)
{
if (disposed_) {
return;
}
LOG_V("GeometryJS::DisposeNative");
disposed_ = true;
SceneJS* sceneJS = static_cast(scn);
if (sceneJS) {
sceneJS->ReleaseDispose(reinterpret_cast(&scene_));
}
if (auto node = interface_pointer_cast(GetNativeObject())) {
if (!IsAttached()) {
if (auto access = interface_pointer_cast(node)) {
access->SetMesh(nullptr).Wait();
}
if (auto scene = node->GetScene()) {
scene->RemoveNode(BASE_NS::move(node)).Wait();
}
}
UnsetNativeObject();
}
scene_.Reset();
}
void GeometryJS::Init(napi_env env, napi_value exports)
{
BASE_NS::vector node_props;
NodeImpl::GetPropertyDescs(node_props);
using namespace NapiApi;
node_props.push_back(GetProperty