LittleJS 1.28.0

Level3D

Prefab3D

An instance of a prefab, what a prefab's type makes: a handle with no shape of its own, and its parts, what the prefab's objects made

  • Parts of a prefab that is not attached are objects of their own in the world: moving, turning or sizing the handle puts them where it now says with its next update, or call placeParts; destroying it destroys them
  • Parts of an attached prefab are its children and move with it as one body

Extends EngineObject3D

Constructor

new Prefab3D(pos3D, prefabName)render3dLevel.js:580

Create an instance of a prefab, made by its type: place one with a level or level3DSpawn

pos3D Vector3 optional
prefabName string optional

A prefab added with level3DAddPrefab

Members

Methods

Inherited from EngineObject3D

Inherited from EngineObject

Members

attached : booleanrender3dLevel.js:591

Are its parts its children, moving with it as one body

From the prefab's origin to the handle, in the prefab's own space: nothing for separate parts, and for an attached prefab the middle of the box around its parts, where its handle is, as an object's place is the middle of its body

partObjects : Array<{id?: number, type: string, pos?: Array<number>, rotation?: Array<number>, scale?: Array<number>|number, properties?: Object}>render3dLevel.js:600

What the prefab's objects made, in the prefab's order

prefabName : stringrender3dLevel.js:589

The prefab it is an instance of

Methods

destroy(immediate)render3dLevel.js:713

Destroy the instance and its parts

immediate boolean optional
placeAt(pos3D)render3dLevel.js:608

Put the instance with its prefab's origin at a place, turned and sized as the handle is: where a level's object or level3DSpawn says it goes; the handle of an attached prefab is then at the middle of its body

pos3D Vector3

Put the parts where the handle is now, making them the first time; called by the handle's update when it has moved, turned or changed size

A prefab's instance has nothing of its own to draw

Keep the parts with the handle, called automatically each frame