LittleJS 1.31.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; its color multiplies the color of the parts that draw their mesh, Box, Sphere, Cylinder, a mesh type and a glTF model, while a part that draws itself, a class of the game's own, a light's glow or particles, keeps its own

Extends EngineObject3D

Constructor

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

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:742

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

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

prefabName : stringrender3dLevel.js:740

The prefab it is an instance of

Methods

destroy(immediate)render3dLevel.js:876

Destroy the instance and its parts

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

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