Documentation

Here I'll explain how the blocks of my extension work in relation of the Three JS functions and methods! I would recommend taking a look at the Three JS documentation.


Guide

  1. Scene
  2. Camera
  3. 3D Objects
  4. Light
  5. Utilities
  6. Addons
  7. Physics

I'll be including tables with images of the blocks and some short descriptions.
Also tables, defining extra properties or the diferent types of concepts.


Scene


Block Definition
new Scene [scene]:: #4638c5 Creates a new scene. Resets current scene. Block to start.
new THREE.Scene()
set Scene [Background v] to (new Color(#96f):: #3875c5):: #4638c5 Sets a property of the scene to a value.
They can be set to a number or an object (Texture, Color).
(get Scene [Objects v]:: #4638c5) Returns a property of the scene. An array of names.

*scene can be seen as a group, the parent group where everything goes.

Camera


add camera [Perspective v] [myCamera] to [scene]:: #38c59b Adds a camera to a group. At [0,0,3] in world space.
By now, only Perspective Camera works.
new THREE.PerspectiveCamera()
set camera [Near v] of [myCamera] to (0.1):: #38c59b Sets a property of a camera to a value. Number.
(get camera [Near v] of [myCamera]:: #38c59b) Returns a property of a camera. Number.
set rendering camera to [myCamera]:: #38c59b Asign the camera that will be used to render the scene.

set a RenderTarget: [myTarget] for camera [myCamera]:: #38c59b Create a RenderTarget with texture of the camera view.
set RenderTarget [myTarget] size to [360] [360]:: #38c59b Adjust the RenderTarget size. It should be proportional to the object size (to avoid streching!).
(get RenderTarget: [myTarget] texture:: #38c59b) Return the texture of the RenderTarget. It beaves as a live texture, no need to update every frame.
remove RenderTarget: [myTarget]:: #38c59b Delete the RenderTarget properly.

3D Objects


Objects are not just 3D meshes, but these object types too. The camera, lights are objects too.

add object [myObject] [Mesh v] to [scene]:: #38c567 Adds an object of a specified type to a group.
 new THREE.Mesh()

Object Types:
clone object [myObject] as [myClone] & add to [scene]:: #38c567 Adds a copy of an already existing object to a group.
Same geometry, material and transforms.
set [Geometry v] of object [myObject] to [myGeometry]:: #38c567 Asign an existing geometry to the object.
Crucial for rendering, to see something.
(get [Geometry v] of object [myObject]:: #38c567) Return the contents of the selected property of the object. Stringified JSON.
<is there an object [myObject]?:: #38c567> Check if the object (anytype) exists.
remove object [myObject] from scene:: #38c567 Deletes the object (anytype) from scene. Does not delete the geometry nor material.
set transform [Position v] of [myObject] to [\[0,0,0\]]:: motion Changes a transform of the object to a vector3.
Position, Rotation, Scale or Facing direction.
Rotation is done in YXZ order.
(get [Position v] of [myObject]:: motion) Returns a vector3 of a transform of the object.

Materials


new material [myMaterial] [Mesh Standard Material v]:: looks Creates a material of a specified type.
new THREE.MeshStandardMaterial()
Material Types:
Check the Materials Table to know what materials enable certain properties
<is there a material [myMaterial]:: looks> Checks if the material exists.
remove material [myMaterial]:: looks Removes the material properly.
material.dispose()
set material [Color v] of [myMaterial] to (new Texture((costume1 v)::looks):: #3875c5):: looks Sets a property of the material to a value. (Number, Color, Texture, Vector2)
Material Properties:
set material [myMaterial] blending to [No Blending v]:: looks Sets the blending mode of the material to a specified type.
Blending Modes:
set material [myMaterial] depth to [Never Depth v]:: looks Sets the depth mode of the material to a specified type.
Depth Modes:

Geometries


new geometry [myGeometry] [Box Geometry v]:: list Creates a new geometry of a specified type.
new THREE.BoxGeometry()
Predefined Geometries: | Box | Sphere | Cylinder | Plane | Circle | Torus | Torus Knot |

Each link contains a pretty good visualization of each one.
<is there a geometry [myGeometry]:: list Checks if the geometry exists.
remove geometry [myGeometry]:: list Removes the geometry properly.
geometry.dispose()
create spline [mySpline] from (generate cruve [CatmullRomCurve3] from points [\[0,3,0\] \[2.5,-1.5,0\] \[-2.5,-1.5,0\]]:: list), closed: [true]:: list Creates a spline geometry of a unique type (for now, CatmullRomCurve3). Use curve.
create text geometry [myText] with text [Hello World!] in font [import v] size (1) depth (0.1) curvedSegments (6):: list Creates a text geometry that displays the given text in a imported font.
To import fonts, use the next buttons:
Convert and Import Font Buttons "Convert font..." will redirect you to facetype.js. This website transforms fonts files (.ttf usually) to json so three can interpret them to generate a geometry.

"Load font..." will open your file explorer, just select the transformed font file (.json) and load it!
Then should appear in font dropdown.

Light


add light [myLight] type [Ambient Light v] to [scene]:: #c7a22a Adds a light of a specified type to the group.
Light types:
set light [myLight] [Intensity v] to [1]:: #c7a22a Sets the light property to a value. Color or Intensity.

Utilities


Here are some utility blocks to use the extension faster and better.
(New Vector [0] [0]:: #3875c5) Returns a Vector2 as an Array. Can be used to set properties of some materials.
[0,0]
(New Vector [0] [0] [0]:: #3875c5) Returns a Vector3 as an Array. Usually to set transforms
[0,0,0]
(move [1] steps in vector [\[0,0,0\]] in direction [\[1,0,0\]]:: #3875c5) Like the move (10) steps block. Needs to be fed a Vector3 direction. Returns a new Vector3.
(direction from [\[0,0,3\]] to [\[0,0,0\]]:: #3875c5) Returns the Vector3 of the direction.
(New Color (#96f):: #3875c5) Returns an [object Object]. Don't mind it. Used to set colors of materials or the scene background.
(New Fog (#96f) (0) (10):: #3875c5) Specify the color, near and far of the fog. Returns an [object Object]. Don't mind it. Used to set the scene fog.
(New Texture ((costume1 v)::#96f) [Pixelate v] [Repeat v] repeat (1) (1):: #3875c5) Creates a texture from a costume. Returns an [object Object]. Don't mind it. Used to set the scene background, all material maps and more...
(New Cube Texture X+((costume1 v)::#96f) X-((costume1 v)::#96f) Y+((costume2 v)::#96f) Y-((costume2 v)::#96f) Z+((costume1 v)::#96f) Z-((costume1 v)::#96f) [Pixelate v] [Repeat v] repeat (1) (1):: #3875c5) Creates a Cube Texture from a costume, to give each face of a 3D cube a specific texture. Same applications as Texture.
(New Equirectangular Texture ((costume1 v)::#96f) [Pixelate v]:: #3875c5) Creates a texture from a 360 costume, like this. Same applications as Texture.
(generate cruve [CatmullRomCurve3] from points [\[0,3,0\] \[2.5,-1.5,0\] \[-2.5,-1.5,0\]]:: list) Used to generate a curve that can be used to create the spline curve geometry.
<mouse [left v] [Down v]?:: sensing Overlaying Three JD on top of scratch disables the mouse down block. I made this block to replace it.
(get item (1) of [\["myObject", "myLight"\]]:: list) Helper block. Returns the item in the Array position (starting on 1). To get an axis from a vector or objects from a raycast.
Raycast from [\[0,0,3\]] in direction [\[0,0,1\]]:: #3875c5 Sends a ray coming from [0,0,3] in direction [0,0,1], every object that the ray goes thru will be stored. For sensing things, grabbing objects?, collisions?...
(get raycast [Intersected Object Names v]:: #3875c5) Get the above raycast results. You can read the number of objects, their names and their distances. (always ordered from closer-further)

Addons


Some extra utilities that deserve their own categories

GLB Importing


Use this button to load and save your .glb model files into the project.
GLB import button It opens the file explorer and saves the model data as a sound in the backdrop.

To dispose a model, delete the sound with the same name.
add [model v] as [myModel] to [scene]::#c53838 Adds the selected preloaded model to the group. It will be added as a group, so when transforming [myModel] all of the children (whole model) gets it.
(get object [Animations v] of [myModel]::#c53838) Some models can come with an animation, get the names of these with this reporter.
play animation [walk] of [myModel], (0) times::#c53838 If the model has animations, place the name here and make it play a certain number of times. 0 times = forever.
set (Pause v) animation [walk] of [myModel]::#c53838 If the model is running an animation, pause it or unpause it.
stop animation [walk] of [myModel]::#c53838 If the model is running an animation, stop it.

Orbit Control


This addon is really useful. It enables a quick way of visualizating the scene with just a toggle.
Left drag to rotate, right to pan and middle to zoom.

set addon Orbit Control (enabled v)::#c538a2

Post Procesing


It modifies the render before its made. Can add cool unique effects. Deeper explanation here.

reset composer::#c538a2 Cleans/Resets added passes. Passes are the effects. Passes are added to the composer.
add bloom intensity:[1] smoothing:[0.5] threshold:[0.5] | blend: [SCREEN] opacity:[1]::#c538a2 Bloom. Take a look at these examples.
add god rays object:[myObject] density:[1] decay:[0.95] weight:[0.4] exposition:[0.1] | resolution:[1] samples:[64] | blend: [SCREEN] opacity:[1]::#c538a2 God rays. Take a look at these examples.
add dots scale:[1] angle:[0] | blend: [SCREEN] opacity:[1]::#c538a2 Comic-Dotted overlay. Take a look at these examples.
add depth of field focusDistance:[3] focalLength:[0.001] bokehScale:[4] | height:[240] | blend: [NORMAL] opacity:[1]::#c538a2 Enables adding a focus point, blurs everything out of the focus range. Take a look at these examples.
add custom shader [myShader] with GLSL fragm [] vert [] | blend: [NORMAL v] opacity:[1]::#c538a2 For advanced composer passes- A bit limited. The next uniforms are avialbe: Resolution and Time. More info here.

Physics


A really complete-easy to understand physics engine. It uses RAPIER physics and Three JS is just the renderer and manager of objects.

create world | gravity [\[0,-9,81,0\]]::#444 Starter block. Set the gravity and start/restart the physics scene.
(get world [Gravity v]::#444) Helper.
enable physics for object [myObject] [on v] | rigidBody [Dynamic v] | collider [Box, Rectangle, cuboid v] density [1] friction [0.5] sensor [false v]::#444 Turns on/off the physics for the object. Take a look at the next definitions:
Physics properties:
RigidBody blocks. RigidBodies are used to simulate the dynamics of non-deformable solids as well as to integrate the trajectory of solids which velocities are controlled by the user.

set rigidbody [Gravity Scale v] of [myObject] to [1]::#444 Changes a property of the rigidbody.
(get rigidbody [Type v] of [myObject]::#444) Return the current value of the property.
RigidBody properties:
lock rigidbody [myObject] [Translation v] on x:(on v) y:(on v) z:(on v)::#444 To prevent a rigid-body from rotating or translating on said axis.
set [Force v] of [myObject] to [\[0,10,0\]] in [World v] space::#444 Forces affect linear velocity. Torques Angular. Impulses both. Check more here.
reset [Forces v] of [myObject]::#444 Cleans any Forces or Torques the object had.
enable Continuous Collision Detection for [myObject] [on v]::#444 Extra precision. More here.

Joints can be used to restric the movement of an object in relation to another.

create FIXED joint between [myObject] & [myObject2] | anchor A: [\[0,0,0\]] [\[0,0,0\]] B: [\[0,1,0\]] [\[0,0,0\]]::#444 Fixed Joint.
create SPHERICAL joint between [myObject] & [myObject2] | anchor A: [\[0,0,0\]] B: [\[0,1,0\]]::#444 Spherical Joint.
create REVOLUTE joint between [myObject] & [myObject2] | anchor A: [\[0,0,0\]] B: [\[1,0,0\]] | axis: [\[0,1,0\]]::#444 Revolute Joint.

*I recommend setting the transform of the objects to the one you place here, else it will go crazy.
The first value for each A/B is for position, if there's a second its for rotation.

Collider blocks.
Colliders represent the geometric shapes that generate contacts and collision events when they touch.
Attaching one or multiple colliders to a rigid body allow the rigid-body to be affected by contact forces.

set collider [Friction v] of [myObject] to [1]::#444 Changes a property of the collider.
(get collider [is Sensor? v] of [myObject]::#444) Returns property values.
Collider properties:

Collider blocks.
Colliders represent the geometric shapes that generate contacts and collision events when they touch.
Attaching one or multiple colliders to a rigid body allow the rigid-body to be affected by contact forces.

<is sensor [mySensor] touching [myObject]?::#444 Checks if a solid object is intersecting with a sensor object.
(objects touching sensor [mySensor]::#444) Returns the names of all objects intersecting with a sensor.