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