• 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
16/// <reference path='./import.ts' />
17
18class ShaderInputBufferModifier extends ModifierWithKey<object> {
19  constructor(value: object) {
20    super(value);
21  }
22  static identity: Symbol = Symbol('shaderInputBuffer');
23  applyPeer(node: KNode, reset: boolean): void {
24    if (reset) {
25      getUINativeModule().component3D.resetShaderInputBuffer(node);
26    } else {
27      getUINativeModule().component3D.setShaderInputBuffer(node, this.value);
28    }
29  }
30  checkObjectDiff(): boolean {
31    if (isResource(this.stageValue) && isResource(this.value)) {
32      return !isResourceEqual(this.stageValue, this.value);
33    } else {
34      return true;
35    }
36  }
37}
38
39class ArkComponent3DComponent extends ArkComponent implements Component3DAttribute {
40  constructor(nativePtr: KNode, classType?: ModifierType) {
41    super(nativePtr, classType);
42  }
43  environment(uri: Resource): Component3DAttribute {
44    throw new Error('Method not implemented.');
45  };
46  customRender(uri: Resource, selfRenderUpdate: boolean): Component3DAttribute {
47    throw new Error('Method not implemented.');
48  };
49  shader(uri: Resource): Component3DAttribute {
50    throw new Error('Method not implemented.');
51  };
52  shaderImageTexture(uri: Resource): Component3DAttribute {
53    throw new Error('Method not implemented.');
54  };
55  shaderInputBuffer(buffer: object): Component3DAttribute {
56    modifierWithKey(this._modifiersWithKeys, ShaderInputBufferModifier.identity, ShaderInputBufferModifier, buffer);
57    return this;
58  };
59  renderWidth(value: Dimension): Component3DAttribute {
60    throw new Error('Method not implemented.');
61  };
62  renderHeight(value: Dimension): Component3DAttribute {
63    throw new Error('Method not implemented.');
64  };
65}
66
67// @ts-ignore
68globalThis.Component3D.attributeModifier = function (modifier: ArkComponent): void {
69  attributeModifierFunc.call(this, modifier, (nativePtr: KNode) => {
70    return new ArkComponent3DComponent(nativePtr);
71  }, (nativePtr: KNode, classType: ModifierType, modifierJS: ModifierJS) => {
72    return new modifierJS.Component3DModifier(nativePtr, classType);
73  });
74};