Note that there are some explanatory texts on larger screens.

plurals
  1. POLoading Flamingo.js model from three.js example morph normals into custom js file
    primarykey
    data
    text
    <p>I am a noob in three.js and webgl, so i was playing with example files inside three.js repo. what I was hoping to achieve is to port the code from one of the example of three.js - "Morph Normal example" where there is a bird flapping its wings. I wanted to import that model into the experiment I was doing with my code. What I did is, I copied the code from morph normal example from ,line 90 to 107 that is loading of flamingo.js model, then I added 2 lines of my code inorder to add that model to scene, I even copied the morphColorsToFaceColors() function at the bottom of the same js file I was editing. But when I start the browser all other model loads but not the flamingo.js it says in console </p> <blockquote> <p>TypeError {} Three.js:632 f.onreadystatechange Three.js:632 DEPRECATED: [flamingo.js] seems to be using old model format </p> <p>get stack: function () { [native code] } message: "Object [object Object] has no method 'offsetHSL'" set stack: function () { [native code] } arguments: null caller: null length: 1 name: "" prototype: Object <strong>proto</strong>: function Empty() {} <strong>proto</strong>: Error</p> </blockquote> <p>Here is my Code that I modified few lines and added to my custom js </p> <pre><code>var mesh = new THREE.Object3D(); mesh.position.y = 48; var loader = new THREE.JSONLoader(); loader.load( "flamingo.js", function( geometry ) { morphColorsToFaceColors( geometry ); geometry.computeMorphNormals(); var material = new THREE.MeshLambertMaterial( { color: 0xffffff, morphTargets: true, morphNormals: true, vertexColors: THREE.FaceColors, shading: THREE.FlatShading } ); var meshAnim = new THREE.MorphAnimMesh( geometry, material ); meshAnim.duration = 800; meshAnim.scale.set( 1.5, 1.5, 1.5 ); meshAnim.position.y = 150; mesh.add(meshAnim); } ); </code></pre> <p>At the end of same js file I am working on I pasted the morphcolorstofacecolors function after the calling of animate() function </p> <pre><code>function morphColorsToFaceColors( geometry ) { if ( geometry.morphColors &amp;&amp; geometry.morphColors.length ) { var colorMap = geometry.morphColors[ 0 ]; for ( var i = 0; i &lt; colorMap.colors.length; i ++ ) { geometry.faces[ i ].color = colorMap.colors[ i ]; geometry.faces[ i ].color.offsetHSL( 0, 0.3, 0 ); } } </code></pre> <p>}</p> <p>The Flamingo.js file is same as it is provided on three.js example.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload