-
-
Save shubham-kaushal/63baa28bf0718972850b8f7fd5f17dae to your computer and use it in GitHub Desktop.
Mockup model generator for THREE.js.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Model mockup */ | |
var colors = [0xcceeee, 0xddeeff, 0xeeccee, 0x00cc00, 0x0000cc, 0xcc3333]; | |
for (i = 0; i < 10; ++i) { | |
var w = 200 * Math.random(); | |
var h = 200 * Math.random(); | |
var d = 5 * Math.random() + 1; | |
var dx = (Math.random() * 40 - 20); | |
var dy = (Math.random() * 40 - 20); | |
var dz = Math.random() * 10; | |
var color = colors[Math.round(Math.random() * 5)]; | |
var material = new THREE.MeshBasicMaterial({ | |
color : color, | |
opacity: 0.4, | |
transparent: true, | |
side: THREE.DoubleSide | |
}); | |
var wire = new THREE.MeshBasicMaterial({ | |
color: color, | |
wireframe: true, | |
wireframeLinewidth: 2 | |
}); | |
var geo = new THREE.CubeGeometry(w, h, d); | |
var mesh1 = new THREE.Mesh(geo, material); | |
var mesh2 = new THREE.Mesh(geo, wire); | |
mesh1.position.x = mesh1.position.x + dx; | |
mesh1.position.y = mesh1.position.y + dy; | |
mesh1.position.z = dz; | |
mesh2.position.x = mesh2.position.x + dx; | |
mesh2.position.y = mesh2.position.y + dy; | |
mesh2.position.z = dz; | |
// add the meshes to the scene | |
scene.add(mesh1); | |
scene.add(mesh2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment