Three.V8

3D rendering engine using JavaScript as user script.

View on GitHub

<–Home

class GLTFModel

A Model that has a GLTF style internal structure.

class GLTFModel extends Object3D

Inheritance Object3D –> GLTFModel

Name Description
Constructors  
GLTFModel() Creates a new GLTFModel.
Properties  
minPos Bounding box min-position.
maxPos Bounding box max-position.
meshes Info of internal meshes.
animations Info of internal animation clips.
Methods  
setTexture Replace a texture using texture name.
batchPrimitives Batch together primitives of the same materials.
setAnimationFrame Assign the current stage of movable parts.
getAnimation Get a loaded animation clip by name.
getAnimations Get all loaded animation clips.
addAnimation Add an animation clip to the model.
addAnimations Add multiple animation clips to the model.
playAnimation Play the animation clip of the given name.
stopAnimation Stop the animation clip of the given name.
updateAnimation Update the movable parts according to the current frame.
setLightmap Set a lightmap image for the model.

Constructors

GLTFModel()

GLTFModel()

Creates a new GLTFModel. Usually not created directly. Use GLTFLoader class to create an GLTFModel.

Properties

See the base Object3D class for common properties.

minPos

.minPos: Object

Read-only property for bounding box min-position.

maxPos

.maxPos: Object

Read-only property for bounding box max-position.

meshes

.meshes: Object

Read-only property for displaying the info of internal meshes.

animations

.animations: Array

Read-only property for displaying the info of internal animation clips.

Methods

See the base Object3D class for common methods.

setTexture()

.setTexture(name: String, image: Image): undefined

Replace the texture of name with image.

.setTexture(name: String, target: GLRenderTarget): undefined

Use the rendering result of target to replace the texture of name.

.setTexture(name: String, mmcamera: MMCamera): undefined

Usa a web-camera image source mmcamera to replace the texture of name.

.setTexture(name: String, mmlazyvideo: MMLazyVideo): undefined

Usa a video-file image source mmlazyvideo to replace the texture of name.

.setTexture(name: String, mmvideo: MMVideo): undefined

Usa a video-file player mmvideo to replace the texture of name.

batchPrimitives()

.batchPrimitives(): undefined

Batch together primitives of the same materials.

setAnimationFrame()

.setAnimationFrame(frame: Object): undefined

Assign the current stage of movable parts using a JS object.

The frame object should have the following properties:

frame.morphs: Array

Optional. Morph state for morphable meshes.

frame.morphs[i].name: String

Name of a morphable mesh.

frame.morphs[i].weights: Array

Weight for each morph target of the mesh.

frame.translations: Array

Optional. Translation states for nodes.

frame.translations[i].name: String

Name of the targeted node.

frame.translations[i].translation: Vector3

Translation state of the node.

frame.rotations: Array

Optional. Rotation states for nodes.

frame.rotations[i].name: String

Name of the targeted node.

frame.rotations[i].rotation: Quaternion

Rotation state of the node.

frame.scales: Array

Optional. Scale states for nodes.

frame.scales[i].name: String

Name of the targeted node.

frame.translations[i].scale: Vector3

Scale state of the node.

getAnimation()

.getAnimation(name: String): Object

Get a loaded animation clip by name.

The returned object has the following properties:

.name: String

Name of the animation clip.

.duration: Number

Duration of the animation clip in seconds.

.morphs: Array

Optional. Morph tracks.

.morphs[i].name: String

Name of the morphable mesh.

.morphs[i].targets: Number

Number of morph targets of the morphable mesh.

.morphs[i].interpolation: String

Interpolation method: “STEP”, “LINEAR” or “CUBICSPLINE”

.morphs[i].times: Float32Array

Time stamp of each frame.

.morphs[i].values: Float32Array

Weight values of each frame.

.translations: Array

Optional. Translation tracks.

.translations[i].name: String

Name of the targeted node.

.translations[i].interpolation: String

Interpolation method: “STEP”, “LINEAR” or “CUBICSPLINE”

.translations[i].times: Float32Array

Time stamp of each frame.

.translations[i].values: Float32Array

Translation values of each frame.

.rotations: Array

Optional. Rotation tracks.

.rotations[i].name: String

Name of the targeted node.

.rotations[i].interpolation: String

Interpolation method: “STEP”, “LINEAR”

.rotations[i].times: Float32Array

Time stamp of each frame.

.rotations[i].values: Float32Array

Rotation values of each frame.

.scales: Array

Optional. Scale tracks.

.scales[i].name: String

Name of the targeted node.

.scales[i].interpolation: String

Interpolation method: “STEP”, “LINEAR” or “CUBICSPLINE”

.scales[i].times: Float32Array

Time stamp of each frame.

.scales[i].values: Float32Array

Scale values of each frame.

getAnimations()

.getAnimations(): Array

Get all loaded animation clips.

Each element of the returned array has the same structure as the return value of .getAnimation().

addAnimation()

.addAnimation(animation: Object): undefined

Add an animation clip to the model.

The animation object should have the same structure as the return value of .getAnimation().

addAnimations()

.addAnimations(animations: Array): undefined

Add multiple animation clips to the model.

Each element of the array should have the same structure as the return value of .getAnimation().

playAnimation()

.playAnimation(name: String): undefined

Play the animation clip of the given name.

stopAnimation()

.stopAnimation(name: String): undefined

Stop the animation clip of the given name.

updateAnimation()

.updateAnimation(): undefined

Update the movable parts according to the current frame. This function should be called from the render callback function.

setLightmap()

.setLightmap(img: HDRImage): undefined

Set a lightmap image for the model.