1/* 2 * Copyright (c) 2023-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/** 17 * @file Defines 3D component 18 * @kit ArkUI 19 */ 20 21/** 22 * Provides methods for controlling the 3d scene 23 * 24 * @typedef { import('../api/@ohos.graphics.scene').Scene } 25 * @syscap SystemCapability.ArkUi.Graphics3D 26 * @atomicservice 27 * @since 12 28 */ 29declare type Scene = import('../api/@ohos.graphics.scene').Scene; 30 31/** 32 * The enum of model type 33 * @enum { number } 34 * @syscap SystemCapability.ArkUi.Graphics3D 35 * @atomicservice 36 * @since 12 37 */ 38declare enum ModelType { 39 /** 40 * Render to texture, gpu would compose this texture to screen. 41 * 42 * @syscap SystemCapability.ArkUi.Graphics3D 43 * @atomicservice 44 * @since 12 45 */ 46 TEXTURE = 0, 47 48 /** 49 * Render to surface, special hardware would compose this surface to screen. 50 * 51 * @syscap SystemCapability.ArkUi.Graphics3D 52 * @atomicservice 53 * @since 12 54 */ 55 SURFACE = 1, 56} 57 58/** 59 * Scene options used by 3D scene control 60 * 61 * @interface SceneOptions 62 * @syscap SystemCapability.ArkUi.Graphics3D 63 * @atomicservice 64 * @since 12 65 */ 66declare interface SceneOptions { 67 /** 68 * ResourceStr type for 3D rendering, Scene type for 3d scene controlling 69 * 70 * @type { ?(ResourceStr | Scene) } 71 * @syscap SystemCapability.ArkUi.Graphics3D 72 * @atomicservice 73 * @since 12 74 */ 75 scene?: ResourceStr | Scene; 76 77 /** 78 * Scene type when 3D rendering 79 * 80 * @type { ?ModelType } 81 * @default ModelType.SURFACE 82 * @syscap SystemCapability.ArkUi.Graphics3D 83 * @atomicservice 84 * @since 12 85 */ 86 modelType?: ModelType; 87} 88 89/** 90 * Defines Component3D. 91 * 92 * @interface Component3DInterface 93 * @syscap SystemCapability.ArkUi.Graphics3D 94 * @atomicservice 95 * @since 12 96 */ 97interface Component3DInterface { 98 /** 99 * SceneOptions used by constructor 100 * 101 * @param { SceneOptions } sceneOptions - The 3D scene controller 102 * @returns { Component3DAttribute } 103 * @syscap SystemCapability.ArkUi.Graphics3D 104 * @atomicservice 105 * @since 12 106 */ 107 (sceneOptions?: SceneOptions): Component3DAttribute; 108} 109 110/** 111 * @extends CommonMethod<Component3DAttribute> 112 * @syscap SystemCapability.ArkUi.Graphics3D 113 * @atomicservice 114 * @since 12 115 */ 116declare class Component3DAttribute extends CommonMethod<Component3DAttribute> { 117 /** 118 * Load 3D model environment resource. 119 * 120 * @param { ResourceStr } uri - The path of 3D environment resource 121 * @returns { Component3DAttribute } The attribute of the component3D 122 * @syscap SystemCapability.ArkUi.Graphics3D 123 * @atomicservice 124 * @since 12 125 */ 126 environment(uri: ResourceStr): Component3DAttribute; 127 128 /** 129 * Set render pipeline of 3D scene render. 130 * 131 * @param { ResourceStr } uri - The path of Render pipeline config file 132 * @param { boolean } selfRenderUpdate - Trigger rendering every frame 133 * @returns { Component3DAttribute } The attribute of the component3D 134 * @syscap SystemCapability.ArkUi.Graphics3D 135 * @atomicservice 136 * @since 12 137 */ 138 customRender(uri: ResourceStr, selfRenderUpdate: boolean): Component3DAttribute; 139 140 /** 141 * Load shader uri. 142 * 143 * @param { ResourceStr } uri - The path of custom shader 144 * @returns { Component3DAttribute } The attribute of the component3D 145 * @syscap SystemCapability.ArkUi.Graphics3D 146 * @atomicservice 147 * @since 12 148 */ 149 shader(uri: ResourceStr): Component3DAttribute; 150 151 /** 152 * Load shader texture uri. 153 * 154 * @param { ResourceStr } uri - The path of texture used by shader 155 * @returns { Component3DAttribute } The attribute of the component3D 156 * @syscap SystemCapability.ArkUi.Graphics3D 157 * @atomicservice 158 * @since 12 159 */ 160 shaderImageTexture(uri: ResourceStr): Component3DAttribute; 161 162 /** 163 * Buffer input for shader animation 164 * 165 * @param { Array<number> } buffer - The uniform buffer of shader input 166 * @returns { Component3DAttribute } The attribute of the component3D 167 * @syscap SystemCapability.ArkUi.Graphics3D 168 * @atomicservice 169 * @since 12 170 */ 171 shaderInputBuffer(buffer: Array<number>): Component3DAttribute; 172 173 /** 174 * Set render width resolution. 175 * 176 * @param { Dimension } value - Width of gpu render target, target would upscale or downscale to view's width. 177 * @returns { Component3DAttribute } The attribute of the component3D 178 * @syscap SystemCapability.ArkUi.Graphics3D 179 * @atomicservice 180 * @since 12 181 */ 182 renderWidth(value: Dimension): Component3DAttribute; 183 184 /** 185 * Set render height resolution. 186 * 187 * @param { Dimension } value - Height of gpu render target, target would upscale or downscale to view's height. 188 * @returns { Component3DAttribute } The attribute of the component3D 189 * @syscap SystemCapability.ArkUi.Graphics3D 190 * @atomicservice 191 * @since 12 192 */ 193 renderHeight(value: Dimension): Component3DAttribute; 194} 195 196/** 197 * Defines Component3D component. 198 * 199 * @syscap SystemCapability.ArkUi.Graphics3D 200 * @atomicservice 201 * @since 12 202 */ 203declare const Component3D: Component3DInterface; 204 205/** 206 * Defines Component3D instance. 207 * 208 * @syscap SystemCapability.ArkUi.Graphics3D 209 * @atomicservice 210 * @since 12 211 */ 212declare const Component3DInstance: Component3DAttribute; 213