Mesh Molecule

Add a 3D mesh.  A mesh can be in Collada (dae), Wavefront (obj), or Three.js (js) formats.

Summary
Mesh Molecule
Preference Dialog
Properties
typestring, ( r )
pref.namestring, ( r )
pref.enableWhenstring, ( r, w )
pref.disableWhenstring, ( r, w )
pref.urlstring, ( r, w )
pref.xfloat, ( r, w )
pref.yfloat, ( r, w )
pref.zfloat, ( r, w )
pref.dxfloat, ( r, w )
pref.dyfloat, ( r, w )
pref.dzfloat, ( r, w )
pref.sxfloat, ( r, w )
pref.syfloat, ( r, w )
pref.szfloat, ( r, w )
pref.fXfloat, ( r, w )
pref.fYfloat, ( r, w )
pref.fZfloat, ( r, w )
pref.fWfloat, ( r, w )
pref.terrainClamppingbool, ( r, w )
pref.clampDownTostring, ( r, w )
pref.frictionfloat, ( r, w )
pref.restitutionfloat, ( r, w )
positionobject, ( r, w )
rotationobject, ( r, w )
worldPositionobject, ( r )
worldRotationobject, ( r )
castShadowbool, ( r, w )
receiveShadowbool, ( r, w )
directionobject, ( r, w )
upobject, ( r, w )
scaleobject, ( r, w )
sizeobject, ( r, w )
boundsobject, ( r )
subdivideint, ( r, w )
visiblebool, ( r )
massfloat, ( r, w )
collisionDetectionbool, ( r, w )
angularVelocityobject, ( r, w )
angularFactorobject, ( w )
linearVelocityobject, ( r, w )
linearFactorobject, ( w )
linearDampingfloat, ( r, w )
angularDampingfloat, ( r, w )
ccdMotionThresholdfloat, ( w )
ccdSweptSphereRadiusfloat, ( w )
meshobject, ( r )
materialobject | string, ( r, w )
coreMaterialobject | string, ( w )
object3Dobject, ( r )
shellobject, ( r )
collisionMarginfloat, ( r, w )
collisionScalefloat, ( w )
pannerobject, ( r )
tracksobject, ( r )
Functions
attach
detach
delete
rename
show
hide
clone
serialize
getUV
setMaterialName
setDepthMaterialName
play
pause
resume
stop
translate
roll
pitch
yaw
rotate
scale
resetOrientation
setSleepingThresholds
setDeactivationTime
setCenterOfMassOffset
applyCentralImpulse
applyImpulse
applyCentralForce
applyForce
applyTorque
applyTorqueImpulse
shatterBake
shatter
shatterDestroy
attachTo
detachFrom

Preference Dialog

Properties

type

string, ( r )

Type of this molecule, mesh.

pref.name

string, ( r )

The scriptable name for this molecule.  This name can be set using rename function dynamically.

pref.enableWhen

string, ( r, w )

Specifies the event that activates this molecule.  Default is load.

pref.disableWhen

string, ( r, w )

Specifies the event that deactivates this molecule.  Default is none.

pref.url

string, ( r, w )

Specifies the URL of this mesh.  This can be a valid http URL or a private vault URL that begins with //.

pref.x

float, ( r, w )

Specifies the x coordinate of this mesh’s position.

pref.y

float, ( r, w )

Specifies the y coordinate of this mesh’s position.

pref.z

float, ( r, w )

Specifies the z coordinate of this mesh’s position.

pref.dx

float, ( r, w )

Specifies the x dimension of this mesh.

pref.dy

float, ( r, w )

Specifies the y dimension of this mesh.

pref.dz

float, ( r, w )

Specifies the z dimension of this mesh.

pref.sx

float, ( r, w )

Specifies the x component of this mesh’s scale.

pref.sy

float, ( r, w )

Specifies the y component of this mesh’s scale.

pref.sz

float, ( r, w )

Specifies the z component of this mesh’s scale.

pref.fX

float, ( r, w )

Specifies the x component of the mesh’s orientation as Quaternion.

pref.fY

float, ( r, w )

Specifies the y component of the mesh’s orientation as Quaternion.

pref.fZ

float, ( r, w )

Specifies the z component of the mesh’s orientation as Quaternion.

pref.fW

float, ( r, w )

Specifies the w component of the mesh’s orientation as Quaternion.

pref.terrainClampping

bool, ( r, w )

Specifies whether this mesh will automatically clamp to the terrain, or any mesh, in the negative-y direction.

pref.clampDownTo

string, ( r, w )

Specifies the name of the entity that this mesh will automatically clamp down to in the negative-y direction.  Default is auto.

pref.friction

float, ( r, w )

Specifies the friction of this mesh on collision.  Default to 0.

pref.restitution

float, ( r, w )

Specifies the restitution (bounciness) of this mesh on collision.  Default to 0.

position

object, ( r, w )

Get/Set the mesh’s position in Vector3 format.

rotation

object, ( r, w )

Get/Set the mesh’s rotation in Vector3 format.

worldPosition

object, ( r )

Returns the mesh’s world position in Vector3 format.

worldRotation

object, ( r )

Returns the mesh’s world rotation in Vector3 format.

castShadow

bool, ( r, w )

Specifies whether this mesh casts shadow.  Default to true.

receiveShadow

bool, ( r, w )

Specifies whether this mesh receives shadow.  Default to true.

direction

object, ( r, w )

Get/Set the mesh’s direction in Vector3.  When animating this mesh along a path, This direction determines how mesh is aligned to path.

up

object, ( r, w )

Gets/Sets the up vector of this mesh.

scale

object, ( r, w )

Gets/Sets the scale of this mesh in Vector3 format.

size

object, ( r, w )

Gets/Sets the size of this mesh in Vector3 format.

bounds

object, ( r )

Returns the bounding cube of this mesh in Vector3 format.

subdivide

int, ( r, w )

Get/Set the mesh’s subdivision.  The higher the value, more vertices are added and the smoother the mesh becomes.  Default to 1 (no subdivide).

visible

bool, ( r )

Returns whether this mesh is visible.

mass

float, ( r, w )

Gets/Sets the weight of this mesh.  Default to 0.

collisionDetection

bool, ( r, w )

Enable/Disable collision detection.

angularVelocity

object, ( r, w )

Gets/Sets this mesh’s angular velocity in Vector3.

angularFactor

object, ( w )

Sets the limit on how much rotational force this mesh will receive in Vector3.

linearVelocity

object, ( r, w )

Gets/Sets this mesh’s linear velocity in Vector3.

linearFactor

object, ( w )

Sets the limit on how much linear force this mesh will receive in Vector3.

linearDamping

float, ( r, w )

Gets/Sets the damping value of this mesh’s linear motion.  Default to 0.

angularDamping

float, ( r, w )

Gets/Sets the damping value of this mesh’s rotational motion.  Default to 0.

ccdMotionThreshold

float, ( w )

Enable Continuous Collision Detection (CCD) motion clampping.  If the motion per simulation step exceeds a given threshold, clamp to the given threshold.  Default to 0.

ccdSweptSphereRadius

float, ( w )

The Continuous Collision Detection (CCD) works on an embedded sphere of radius.  Make sure this radius is embedded inside the convex objects, preferably smaller.  For object of dimension 1, use 0.2f.  Default to 0.

mesh

object, ( r )

Returns this mesh molecule’s internal mesh object.

material

object | string, ( r, w )

Returns this mesh’s material object or Sets this mesh’s material using path (e.g. app.molecule.material) or raw material object.

coreMaterial

object | string, ( w )

Sets this mesh’s internal material to be applied to shattered fragments.

object3D

object, ( r )

Returns this mesh’s internal object3D object.

shell

object, ( r )

Returns this mesh’s internal shell for collision detection.

collisionMargin

float, ( r, w )

Gets/Sets the collision margin of this mesh’s internal collision shell.  Initialized to 0.

collisionScale

float, ( w )

Gets/Sets the scale of this mesh’s internal collision shell (as Vector3).

panner

object, ( r )

Returns this mesh’s sound panner object, if a web audio sound source is attached to this mesh.

tracks

object, ( r )

Returns this mesh’s animation and audio tracks.  (see tracks.Comments.)

Functions

attach

attach(droplet);

Attach this molecule to the given droplet.

Parameters

droplet(object) a droplet.

Returns

N/A

detach

detach();

Remove this molecule from its droplet.

Parameters

N/A

Returns

N/A

delete

delete();

Delete this molecule.

Parameters

N/A

Returns

N/A

rename

rename(name);

Rename this molecule.

Parameters

name(string) a new name.

Returns

N/A

show

show();

Shows this mesh.

Parameters

N/A

Returns

N/A

hide

hide();

Hides this mesh.

Parameters

N/A

Returns

N/A

clone

clone();

Create a clone of this molecule.

Parameters

N/A

Returns

(object) a molecule.

serialize

serialize();

Serialize this molecule into its JSON representation.

Parameters

N/A

Returns

(string) JSON representation of a molecule.

getUV

getUV(point, face, index);

Given a point in space and the mesh’s face where the point lies, this function returns the UV coordinate of the indexed UV set.

Parameters

point(object) a point in space.  (e.g as returned by Camera Molecule.rayCastSelect.)
face(object) a face on the mesh.  (e.g as returned by Camera Molecule.rayCastSelect.)
index(int) index of a UV coordinate set.  Default to 0.

Returns

N/A

setMaterialName

setMaterialName(name, submesh_index);

Sets the material of this mesh.

Parameters

name(string) an unique name of the material.  (e.g.  ‘materialName’, ‘materialMoleculeName.materialName’, ‘dropletName.materialMoleculeName.materialName’, or ‘app.dropletName.materialMoleculeName.materialName’).
submesh_index(int) optional.  If this mesh is made of multiple sub-meshes each with different material.  You can set each sub-mesh’s material by its index.

Returns

N/A

setDepthMaterialName

setDepthMaterialName(name, submesh_index);

Sets the depth material of this mesh.

Parameters

name(string) an unique name of the material.  (e.g.  ‘materialName’, ‘materialMoleculeName.materialName’, ‘dropletName.materialMoleculeName.materialName’, or ‘app.dropletName.materialMoleculeName.materialName’).
submesh_index(int) optional.  If this mesh is made of multiple sub-meshes each with different material.  You can set each sub-mesh’s material by its index.

Returns

N/A

play

play(start_time, end_time, toLoop);
play(toLoop, period);

Play all animation tracks of this mesh between start_time and end_time.

Parameters

start_time(int) Optional.  Start time in msec.  Default is 0.
end_time(int) Optional.  End time in msec.  Default to the total length of animation.
toLoop(bool) Optional.  Set to true to repeat the animation indefinitely.  Default to false.
period(int) Optional.  If toLoop is true, repeat the track segment of length given by this value.

Returns

N/A

pause

pause();

Pause the animation.

Parameters

N/A

Returns

N/A

resume

resume();

Resume the animation.

Parameters

N/A

Returns

N/A

stop

stop();

Stop the animation and rewind to beginning.

Parameters

N/A

Returns

N/A

translate

translate(v3, ts);

Translate this mesh by the given vector v3 and in the coordinate space given by ts.

Parameters

v3(object) a Vector3.
ts(constant) TS_LOCAL, TS_PARENT, or TS_WORLD.  Default to TS_LOCAL.

Returns

N/A

roll

roll(d, ts);

Roll this mesh by the given degree d and in the coordinate space given by ts.

Parameters

d(float) an angle in degree.
ts(constant) TS_LOCAL, TS_PARENT, or TS_WORLD.  Default to TS_LOCAL.

Returns

N/A

pitch

pitch(d, ts);

Pitch this mesh by the given degree d and in the coordinate space given by ts.

Parameters

d(float) an angle in degree.
ts(constant) TS_LOCAL, TS_PARENT, or TS_WORLD.  Default to TS_LOCAL.

Returns

N/A

yaw

yaw(d, ts);

Yaw this mesh by the given degree d and in the coordinate space given by ts.

Parameters

d(float) an angle in degree.
ts(constant) TS_LOCAL, TS_PARENT, or TS_WORLD.  Default to TS_LOCAL.

Returns

N/A

rotate

rotate(axis, d, ts);

Rotate this mesh by the given degree d around the axis and in the coordinate space given by ts.

Parameters

axis(object) a Vector3.
d(float) an angle in degree.
ts(constant) TS_LOCAL, TS_PARENT, or TS_WORLD.  Default to TS_LOCAL.

Returns

N/A

scale

scale(ratio);

Scale this mesh by the given ratio.

Parameters

ratio(mixed) If the ratio is Vector3, the mesh’s current scale is multiplied by the Vector3 component-wise.  If the ratio is float, the mesh’s current scale is scaler-multiplied by the float.

Returns

N/A

resetOrientation

resetOrientation();

Reset this mesh’s orientation.  All rotation is reset to 0.

Parameters

N/A

Returns

N/A

setSleepingThresholds

setSleepingThresholds(linear, angular);

Sets the mesh’s sleeping threshold.  Speed at the given values or lower for a time period given by the deactivation time will puts the mesh into sleep state.

Parameters

linear(float) linear velocity
angular(float) angular velocity

Returns

N/A

setDeactivationTime

setDeactivationTime(time);

Sets the mesh’s deactivation time.  Speed at the given values or lower for a time period given by the deactivation time will puts the mesh into sleep state.

Parameters

time(float) time in secs

Returns

N/A

setCenterOfMassOffset

setCenterOfMassOffset(offset);

Apply an offset to the center of mass.

Parameters

offset(object) translation in Vector3.

Returns

N/A

applyCentralImpulse

applyCentralImpulse(impulse);

Apply an impulse at this mesh’s center of mass.

Parameters

impulse(object) direction and magnitude of the impulse in Vector3.

Returns

N/A

applyImpulse

applyImpulse(impulse, offset);

Apply an impulse at this mesh’s center of mass with an offset.

Parameters

impulse(object) direction and magnitude of the impulse in Vector3.
offset(object) an offset from the center of mass.

Returns

N/A

applyCentralForce

applyCentralForce(force);

Apply a constant force at this mesh’s center of mass.

Parameters

force(object) direction and magnitude of the force in Vector3.

Returns

N/A

applyForce

applyForce(force, offset);

Apply a constant force at this mesh’s center of mass with an offset.

Parameters

force(object) direction and magnitude of the force in Vector3.
offset(object) an offset from the center of mass.

Returns

N/A

applyTorque

applyTorque(torque);

Apply a constant torque on this mesh.

Parameters

torque(object) rotational force in Vector3.

Returns

N/A

applyTorqueImpulse

applyTorqueImpulse(torque);

Apply a torque impulse on this mesh.

Parameters

torque(object) rotational force in Vector3.

Returns

N/A

shatterBake

shatterBake(fragment_count, callback);
shatterBake(fragment_count, force_direction, center_offset, entry_diameter, exit_diameter, callback);

Initiate the baking process for generating Voronoi fragments in a worker thread.

Parameters

fragment_count(int) the number of fragments to be generated.
force_direction(object) the direction of impact force in Vector3.
center_offset(object) the offset of the impact point from the mesh’s geometric center.
entry_diameter(int) the size of the entry point.
exit_diameter(int) the size of the exit point.
callback(function) a function for receiving the notification of process completion.

Returns

N/A

shatter

shatter(initial_velocity);

Shows the pre-generated shatter fragments and hide the original mesh.

Parameters

initial_velocity(object) the initial velocity applied to fragments in Vector3.

Returns

N/A

shatterDestroy

shatterDestroy();

Remove all shatter fragments from the scene.

Parameters

N/A

Returns

N/A

attachTo

attachTo(entity);

Attach this mesh to the given 3D entity.

Parameters

entity(object) a mesh, light, manualobject, or particle molecule.

Returns

N/A

detachFrom

detachFrom();

Detach this mesh from its parent, if any.

Parameters

N/A

Returns

N/A

Each Mesh Molecule can have a set of morph, skeletal, path animation and audio tracks.
Close