GltfAsset
ClassRepresents a GLTF 3D Model.
- Available on all platforms
Since Lens Scripting v176
Index
Properties
Methods
Example
// @input Asset.BitmojiModule bitmojiModule
// @input Asset.RemoteMediaModule remoteMediaModule
// @input Asset.Material pbrMaterialHolder
script.bitmojiModule.requestBitmoji3DResource(
function (bitmoji3DResource) {
script.remoteMediaModule.loadResourceAsGltfAsset(
bitmoji3DResource,
onDownloaded,
onFail
)
}
)
function onDownloaded (gltfAsset){
var root = scene.createSceneObject("BitmojiAvatar");
var gltfSettings = GltfSettings.create();
gltfSettings.convertMetersToCentimeters = true;
var avatar = gltfAsset.tryInstantiateWithSetting(root, script.pbrMaterialHolder, gltfSettings);
}
function onFail (e){
print(e);
}
Extends
Properties
extras
readonlyextras:string
Since
Lens Scripting Version 176
name
name:
string
The name of the Asset in Lens Studio.
Default Value
""
Inherited from
uniqueIdentifier
readonlyuniqueIdentifier:string
Since
Lens Scripting Version 176
Inherited from
Methods
getResourceFromExtras()
getResourceFromExtras(
url):DynamicResource
Use this method to get a dynamic resource for the url from the gltf extras.
Parameters
| Parameter | Type |
|---|---|
url | string |
Returns
Since
Lens Scripting Version 313
getStaticComposition()
getStaticComposition():
string
Returns a JSON string containing statistics about the glTF asset including: file size, triangle count, vertex count, mesh count, texture count, texture memory size, material count, animation count, and node count. Must be called after the asset has been instantiated with tryInstantiate, tryInstantiateAsync or tryInstantiateWithSetting, otherwise it returns null.
Returns
string
Since
Lens Scripting Version 340
Example
var info = gltfAsset.getStaticComposition();
if (info) {
var stats = JSON.parse(info);
print("Triangles: " + stats.triangleCount);
print("File size: " + stats.fileSizeBytes + " bytes");
}
getTypeName()
staticgetTypeName():TypeName<GltfAsset>
Returns the fully-qualified JavaScript type name for this class (for example, "Component.Camera"). This is a static accessor (no instance required) and returns the same value as the instance getTypeName().
Returns
TypeName<GltfAsset>
Since
Lens Scripting Version 176
Overrides
getTypeName()
getTypeName():
string
Returns the name of this object's type.
Returns
string
Inherited from
isOfType()
isOfType(
type):boolean
Returns true if the object matches or derives from the passed in type.
Parameters
| Parameter | Type |
|---|---|
type | string |
Returns
boolean
Inherited from
isSame()
isSame(
other):boolean
Returns true if this object is the same as other. Useful for checking if two references point to the same thing.
Parameters
| Parameter | Type |
|---|---|
other | ScriptObject |
Returns
boolean
Inherited from
tryInstantiate()
tryInstantiate(
parent,material):SceneObject
Try instantiating an object from the GLTF asset.
Parameters
| Parameter | Type |
|---|---|
parent | SceneObject |
material | Material |
Returns
Since
Lens Scripting Version 176
tryInstantiateAsync()
tryInstantiateAsync(
parent,material,onSuccess,onFailure,onProgress,gltfSettings?):void
Asynchronously try instantiating an object from the GLTF asset. Useful to prevent frame drops when loading multiple assets simultaenously as to not block the the thread.
Parameters
| Parameter | Type |
|---|---|
parent | SceneObject |
material | Material |
onSuccess | (sceneObject) => void |
onFailure | (error) => void |
onProgress | (progress) => void |
gltfSettings? | GltfSettings |
Returns
void
Since
Lens Scripting Version 300
tryInstantiateWithSetting()
tryInstantiateWithSetting(
parent,material,gltfSettings):SceneObject
Try instantiating an object from the GLTF asset with supplied GltfSetting
Parameters
| Parameter | Type |
|---|---|
parent | SceneObject |
material | Material |
gltfSettings | GltfSettings |
Returns
Since
Lens Scripting Version 183