forked from Art-151/babylon-basic
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathart151.js
32 lines (29 loc) · 1.1 KB
/
art151.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
//draw sphere at specified position of specified diameter
function createSphere(x, y, z, diam, scene){
// babylon built-in 'sphere' shape.
var sphere = BABYLON.MeshBuilder.CreateSphere("sphere", {diameter: diam, segments: 32}, scene);
// Move the x, y, z position
sphere.position = new BABYLON.Vector3(x, y, z);
return sphere;
}
//draw box at specified position of specified length, width, depth
function createBox(x, y, z, w, h, d, scene){
// babylon built-in 'sphere' shape.
var box = BABYLON.MeshBuilder.CreateBox("box", {height:h, width:w, depth: d}, scene);
// Move the x, y, z position
box.position = new BABYLON.Vector3(x, y, z);
return box;
}
//create material from image file
function fileMat(file, scene){
//create material
var mat = new BABYLON.StandardMaterial('material', scene);
mat.diffuseTexture = new BABYLON.Texture(file, scene);
return mat;
}
//create material from hex color
function hexMat(hex, scene){
var mat = new BABYLON.StandardMaterial('material', scene);
mat.diffuseColor = BABYLON.Color3.FromHexString(hex);
return mat;
}