new MTLLoader()
.setPath( 'models/obj/male02/' )
.load( 'male02.mtl', function ( materials ) {
materials.preload();
new OBJLoader()
.setMaterials( materials )
.setPath( 'models/obj/male02/' )
.load( 'male02.obj', function ( object ) {
object.position.y = - 0.95;
object.scale.setScalar( 0.01 );
scene.add( object );
}, onProgress );
} );
let object ; let object2 ;
// manager
function loadModel() {
object.traverse( function ( child ) {
if ( child.isMesh ) child.material.map = texture;
} );
object.position.y =0.2;
object.position.z =-2;
object.position.x =-32;
object.scale.setScalar( 0.1 );
scene.add( object );
render();
}
const manager = new THREE.LoadingManager( loadModel );
// texture
const textureLoader = new THREE.TextureLoader( manager );
const texture = textureLoader.load( 'textures/brick_diffuse.jpg', render );
texture.colorSpace = THREE.SRGBColorSpace;
// model
function onProgress( xhr ) {}
function onError() {}
const loader = new OBJLoader( manager );
loader.load( 'model/model4.obj', function ( obj ) {
object = obj;
}, onProgress, onError );
function loadModel2() {
object2.traverse( function ( child ) {
if ( child.isMesh ) child.material.map = texture;
} );
object2.position.y =0.2;
object2.position.z =-2;
object2.position.x =-52;
object2.scale.setScalar( 0.1 );
scene.add( object2 );
render();
}
const manager2 = new THREE.LoadingManager( loadModel2 );
// texture
const textureLoader2 = new THREE.TextureLoader( manager2 );
const texture2 = textureLoader2.load( 'textures/brick_diffuse.jpg', render );
texture2.colorSpace = THREE.SRGBColorSpace;
// model
function onProgress( xhr ) {}
function onError() {}
const loader2 = new OBJLoader( manager2 );
loader2.load( 'model/model3.obj', function ( obj ) {
object2 = obj;
}, onProgress, onError );
# Material Count: 5
newmtl _01_-_Default1noCulli__01_-_Default1noCulli
Ns 30.0000
Ka 0.640000 0.640000 0.640000
Kd 0.640000 0.640000 0.640000
Ks 0.050000 0.050000 0.050000
Ni 1.000000
d 1.000000
illum 2
map_Kd 01_-_Default1noCulling.JPG
newmtl FrontColorNoCullingID_male-02-1noCulling.JP
Ns 30.0000
Ka 0.800000 0.800000 0.800000
Kd 0.800000 0.800000 0.800000
Ks 0.050000 0.050000 0.050000
Ni 1.000000
d 1.000000
illum 2
map_Kd male-02-1noCulling.JPG
newmtl male-02-1noCullingID_male-02-1noCulling.JP
Ns 30.0000
Ka 0.640000 0.640000 0.640000
Kd 0.640000 0.640000 0.640000
Ks 0.050000 0.050000 0.050000
Ni 1.000000
d 1.000000
illum 2
map_Kd male-02-1noCulling.JPG
newmtl orig_02_-_Defaul1noCu_orig_02_-_Defaul1noCu
Ns 30.0000
Ka 0.640000 0.640000 0.640000
Kd 0.640000 0.640000 0.640000
Ks 0.050000 0.050000 0.050000
Ni 1.000000
d 1.000000
illum 2
map_Kd orig_02_-_Defaul1noCulling.JPG
newmtl FrontColorNoCullingID_orig_02_-_Defaul1noCu
Ns 30.0000
Ka 0.800000 0.800000 0.800000
Kd 0.800000 0.800000 0.800000
Ks 0.050000 0.050000 0.050000
Ni 1.000000
d 1.000000
illum 2
map_Kd orig_02_-_Defaul1noCulling.JPG
// model
const onProgress = function ( xhr ) {
if ( xhr.lengthComputable ) {
const percentComplete = xhr.loaded / xhr.total * 100;
console.log( percentComplete.toFixed( 2 ) + '% downloaded' );
}
};
new MTLLoader()
.setPath( 'male02/' )
.load( 'male02.mtl', function ( materials ) {
materials.preload();
new OBJLoader()
.setMaterials( materials )
.setPath( 'male02/' )
.load( 'male02.obj', function ( object ) {
object.position.y = - 0.95;
object.scale.setScalar( 0.01 );
scene.add( object );
}, onProgress );
} );
const onProgress3 = function ( xhr ) { };
new MTLLoader()
.setPath( 'male02/' )
.load( 'male02.mtl', function ( materials ) {
materials.preload();
new OBJLoader()
.setMaterials( materials )
.setPath( 'male02/' )
.load( 'male02.obj', function ( object3 ) {
object3.position.y = 0.34;
object3.position.x = -25;
object3.position.z = 5;
object3.scale.setScalar( 0.02 );
scene.add( object3 );
}, onProgress );
} );
//
function init() {
setInterval(my_timer, 4000);
setInterval(my_timer, 4000);
function my_timer()
{
object2.position.z +=10;
} // my_timer
let objects=[];
let count=50;
const geometry_hsr = new THREE.CylinderGeometry( 0.2, 0.2, 10, 32 );
const texture_hsr = new THREE.TextureLoader().load( 'wood2.jpg' );
const material_hsr = new THREE.MeshBasicMaterial( { map: texture_hsr } );
for ( var i = 0; i < count; i ++ )
{
var mesh_hsr = new THREE.Mesh(geometry_hsr, material_hsr);
scene.add(mesh_hsr);
objects.push(mesh_hsr);
// initial individual transfo
mesh_hsr.position.set(-10, 0.3 , 10+(5*i) );
}
CylinderGeometry(radiusTop : Float, radiusBottom : Float, height : Float, radialSegments : Integer, heightSegments : Integer, openEnded : Boolean, thetaStart : Float, thetaLength : Float)
<script src="js/Three.js"></script>
<script src="js/Detector.js"></script>
<script src="js/Stats.js"></script>
<script src="js/OrbitControls.js"></script>
<script src="js/THREEx.KeyboardState.js"></script>
<script src="js/THREEx.FullScreen.js"></script>
<script src="js/THREEx.WindowResize.js"></script>
<!doctype html>
<html>
<body>
<canvas width = "300" height = "300" id = "my_Canvas"></canvas>
<script>
/* Step1: Prepare the canvas and get WebGL context */
var canvas = document.getElementById('my_Canvas');
var gl = canvas.getContext('experimental-webgl');
/* Step2: Define the geometry and store it in buffer objects */
var vertices = [-0.5, 0.5, -0.5, -0.5, 0.0, -0.5,];
// Create a new buffer object
var vertex_buffer = gl.createBuffer();
// Bind an empty array buffer to it
gl.bindBuffer(gl.ARRAY_BUFFER, vertex_buffer);
// Pass the vertices data to the buffer
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW);
// Unbind the buffer
gl.bindBuffer(gl.ARRAY_BUFFER, null);
/* Step3: Create and compile Shader programs */
// Vertex shader source code
var vertCode =
'attribute vec2 coordinates;' +
'void main(void) {' + ' gl_Position = vec4(coordinates,0.0, 1.0);' + '}';
//Create a vertex shader object
var vertShader = gl.createShader(gl.VERTEX_SHADER);
//Attach vertex shader source code
gl.shaderSource(vertShader, vertCode);
//Compile the vertex shader
gl.compileShader(vertShader);
//Fragment shader source code
var fragCode = 'void main(void) {' + 'gl_FragColor = vec4(0.0, 0.0, 0.0, 0.1);' + '}';
// Create fragment shader object
var fragShader = gl.createShader(gl.FRAGMENT_SHADER);
// Attach fragment shader source code
gl.shaderSource(fragShader, fragCode);
// Compile the fragment shader
gl.compileShader(fragShader);
// Create a shader program object to store combined shader program
var shaderProgram = gl.createProgram();
// Attach a vertex shader
gl.attachShader(shaderProgram, vertShader);
// Attach a fragment shader
gl.attachShader(shaderProgram, fragShader);
// Link both programs
gl.linkProgram(shaderProgram);
// Use the combined shader program object
gl.useProgram(shaderProgram);
/* Step 4: Associate the shader programs to buffer objects */
//Bind vertex buffer object
gl.bindBuffer(gl.ARRAY_BUFFER, vertex_buffer);
//Get the attribute location
var coord = gl.getAttribLocation(shaderProgram, "coordinates");
//point an attribute to the currently bound VBO
gl.vertexAttribPointer(coord, 2, gl.FLOAT, false, 0, 0);
//Enable the attribute
gl.enableVertexAttribArray(coord);
/* Step5: Drawing the required object (triangle) */
// Clear the canvas
gl.clearColor(0.5, 0.5, 0.5, 0.9);
// Enable the depth test
gl.enable(gl.DEPTH_TEST);
// Clear the color buffer bit
gl.clear(gl.COLOR_BUFFER_BIT);
// Set the view port
gl.viewport(0,0,canvas.width,canvas.height);
// Draw the triangle
gl.drawArrays(gl.TRIANGLES, 0, 3);
</script>
</body>
</html>