Documentation

scratch3d edited this page Oct 10, 2015 · 52 revisions

Blocks

New 3D World

The "New 3D World" block allows the programmer to add a new 3-dimensional scene to their program. Full Block Documentation

Add Camera Controls

The "Add Camera Controls" block allows the programmer to add in a specified camera controls to their scene and control the speed at which the camera both moves and rotates. Full Block Documentation

Camera Look At

The "Camera Look At" block focus the camera on a specified side of a specified object. Fallowing that object and staying focussed on the given side of the object, even as the object moves and rotates within the scene. Full Block Documentation

Move Camera

The "Move Camera" block will move your scenes current camera a given number of steps in a given direction.

Rotate Camera

The "Rotate Camera" block will rotate your camera by a given number of degrees in a specified direction. This block can rotate your camera along all 3-axis. (X,Y,Z)

  • "Left" is a positive rotation along the Y axis.
  • "Right" is a negative rotation along the Y axis.
  • "Up" is a positive rotation along the X axis.
  • "Down" is a negative rotation along the X axis.
  • "Roll Left" is a positive rotation along the Z axis.
  • "Roll Right" is a negative rotation along the Z axis.

New Shape

The "New Shape" block allows you to easy add basic geometric shapes to your scene. The block currently has nine different geometric shapes from which you can choose. The dimensions of the different geometries can be altered by specifying different values in the 3 input fields after "Size:". Also the position of the geometry within your scene can be manipulated by changing the values in the X, Y, and Z input fields.

New Light

The "New Light" block adds a new light of a given type, color, intensity, and position. To change the color of the light for basic colors you can just enter the color name exp. red, green, blue. (Must be entered in all lowercase) The block can also take in any hexadecimal representation of a color. exp. "#FF0000" (red)

New Characters

The "New Character" block allows you to add pre-made characters and models to your scene. Scratch3d currently only has a few models but we are currently working on getting many more.

(If you have any 3d models or characters you would like to see added to the Scratch3d extension feel free to send suggestions or even better 3d models to scratch3dmodels@gmail.com. .stl, .obj or .blender files are preferred)

New Planet

The "New Planet" block allows you to create a 3d model of any of the major celestial bodies with in our solar system using just one block. The size and position of the planet can also be specified in the block. This block uses the Threex.planets extension for THREE.js created by Jerome Etienne.

Move

The "Move" block gives you the ability to programmatically move objects around in your scene. Using this block, objects such as shapes, and characters can be moved a given number of steps in a given direction each time the block is called. The "Variable" that this block takes in is a specific geometry variable that your have previously created in your scratch code. For example a shape, planet, or character.

  • "Left" moves your object along the negative X-axis.
  • "Right" moves your object along the positive X-axis.
  • "Up" moves your object along the positive Y-axis.
  • "Down" moves your object along the negative Y-axis.
  • "Forward" moves your object along the negative Z-axis.
  • "Back" moves your object along the positive Z-axis.

Rotate

The "Rotate" block allows you to rotate a specified object such as a shape a given number of degrees in a given direction. The "Variable" that this block takes in is a specific geometry variable that must have been previously created in your scratch code. For example a shape, planet, or character.

  • A negative number of degrees along the Y-axis will rotate your object right.
  • A positive number of degrees along the Y-axis will rotate your object left.
  • A negative number of degrees along the X-axis will rotate your object down.
  • A positive number of degrees along the X-axis will rotate your object up.
  • A negative number of degrees along the Z-axis will roll your object right.
  • A positive number of degrees along the Z-axis will roll your object left.

New Material

The "New Material" block allows you to create materials to add to your geometry's, most commonly to shapes. This in return allows you to change the color of those objects and even map images to them.

Change Material Color

The "Change Material Color" block allows you to give the materials you create a specific color. To change the color of the material for basic colors can be done by entering just the name of the color exp. red, green, blue. (Must be entered in all lowercase) The block can also take in any hexadecimal representation of a color too. exp. "#FF0000" (red)

Set Material Image

The "Set Material Image" block allows you to add a image to a given material. For example passing a material variable into the block and selecting the "Crate" option from the drop down menu will allow you to create a object that looks like a crate when the material is applied to a cube.

Apply Material

The apply material block allows you to change the look of a given geometry to that of a material you have perviously created in you scratch code.

Apply FPV Controls to Object

The "Apply FPV Controls to Object" block allows you to easily add keyboard controls to you character. Giving you the ability to navigate your character through your scene from a first person view point. This block takes in a "Variable", the object you wish to apply the first person controls to, a "Move Speed", the speed at which your object will move through your scene and a "Look Speed", how quickly your object will turn left or right to look around your scene.

  • "Left Arrow" moves your object left.
  • "Right Arrow" moves your object right.
  • "Up Arrow" moves your object forward, or along the Z-axis in the negative direction.
  • "Down Arrow" moves your object back, or along the Z-axis in the positive direction.
  • "A" key turns your object left, or rotates it a positive number of degrees along the Y-axis.
  • "D" key turns your object right, or rotates it a negative number of degrees along the Y-axis.

Scale

The scale block allows you to change the size of a given geometry. i.e A character, shape or planet. To increase the size of a object pass in values greater than 1 for the X,Y, and Z axis and less than 1 to shrink the object.

When Key Pressed

The "When Key Pressed" hat blocks allows you to control what happens in you scene when the user presses a key. Certain keys cannot be used when other blocks are being used. For example you cannot use the arrow keys, A key or D key when using the "Apply FPV Controls" block because those keys are already being used by that block. This block is used when using Scratch3d instead of the regular "When Key Pressed" hat block in scratch because it increases the efficiency of your program.

Physics Blocks

New Physics Material

The "New Physics Material" block allows you to add physics simulations to your scratch3D program. Scratch3D utilizes the Physijs physics plug in for Three.js (http://chandlerprall.github.io/Physijs/). This block takes in three arguments, A material type, A friction value ranging from 0 to 1, and a Restitution value(bounciness) ranging from 0 to 1. A a object with a physics material applied to it will only interact with other objects that have physics materials applied to them. YOU MUST ALSO have gravity turned ON in your "New 3d World" block to use physics materials in your program.

Set Friction

The "Set Friction" block takes in a object that has already had a physics material applied to it and changes the friction value of that object to whatever value passed into it. These values only range between 0.0 to 1.0.

Set Restitution Of

The "Set Restitution" block changes the bounciness of an object that has had a physics material applied to it. It takes in two arguments, first an object that has had a physics material applied to it and second a value ranging from 0.0 to 1.0.

Set Weight Of

The "Set Weight" block allows you to change the weight of the object you pass into it. The block takes in two arguments, first a object that has had a physics material applied to it and second the new weight value you wish to add to the object passed in as the first argument.

Set Linear Velocity

The "Set Linear Velocity" block allows you to set the velocity of an object. A real world example of this is like throwing a ball. If you throw a ball in the air it will start moving in a given direction depending how much froce you apply to it in the x, y and z direction. As it travels though the air though gravity will eventual pull it back to the ground. Friction will also play a role in the movement of the ball. This block takes in four arguments.

*A object that has already had a physics material applied to it. *A velocity value for the objects X, Y, and Z axis. A negative value passed into the X axis will move the object left. A positive value passed into the X axis will move the object right. A negative value passed into the Y axis will move the object down. A positive value passed into the Y axis will move the object up. A negative value passed into the Z axis will move the object forward. A positive value passed into the Z axis will move the object backward.

Set Angular Velocity

The "Set Angular Velocity" allows you to adjust the rotational velocity of an object. Angular Velocity is very similar to Linear Velocity except for the fact that angular velocity determines how fast a object will spin along each of its axis.