Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <!-- Using ThreeJS r98 (Oct 2018) -->
<script src="//cdn.rawgit.com/mrdoob/three.js/5360a81b8c557ed255e97b87c49e7d00b546b795/build/three.min.js"></script>
<script src="//cdn.rawgit.com/mrdoob/three.js/5360a81b8c557ed255e97b87c49e7d00b546b795/examples/js/controls/OrbitControls.js"></script>

<body>
  <div id='text'>
    This is a test to see if the bouding box is updated with the animation (ThreeJS r98).<br />
    <a href="https://discourse.threejs.org/t/object-bounds-not-updated-with-animation" target="_blank">https://discourse.threejs.org/t/object-bounds-not-updated-with-animation</a>
  <div id='info'>ghjfghjf</div>
</body>
              
            
!

CSS

              
                body {
  margin: 0;
}
canvas {
  width: 100%;
  height: 100%;
}
#text {
  position: absolute;
}
#info {
  display:block;
}
              
            
!

JS

              
                // --- Init --- //
var info = document.querySelector('#info');
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera( 75, window.innerWidth/window.innerHeight, 1, 1000 );

camera.position.x = -250;
camera.position.y = 200;
camera.position.z = -200;

var renderer = new THREE.WebGLRenderer();
renderer.setClearColor(0xCCCCCC, 1);
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );

var controls = new THREE.OrbitControls( camera, renderer.domElement );
//controls.enableZoom = false;
controls.enablePan = false;
controls.maxPolarAngle = Math.PI/2.5;

//var gridHelper = new THREE.GridHelper(400, 10, 0x666666, 0x666666);
//scene.add( gridHelper );

window.addEventListener( 'resize', onWindowResize, false );

function onWindowResize() {
  camera.aspect = window.innerWidth / window.innerHeight;
  camera.updateProjectionMatrix();
  renderer.setSize( window.innerWidth, window.innerHeight );
}


// --- Object --- //
//var url = "https://threejs.org/examples/models/skinned/marine/marine_anims_core.json";
var url = "https://cdn.rawgit.com/mrdoob/three.js/5360a81b8c557ed255e97b87c49e7d00b546b795/examples/models/skinned/marine/marine_anims_core.json";
var object, objectMesh, objectBox, objectBounds, skeletonHelper, boxHelper;

function initObject() {
  new THREE.ObjectLoader().load(
    url,
    function ( loadedObject ) {
      object = loadedObject;
      // Get the object mesh.
      object.traverse( function ( child ) {
        if ( child instanceof THREE.SkinnedMesh ) {
          objectMesh = child;
        }
      });
      
      // Add object to scene.
      scene.add( object );
      
      // Add skeleton.
      skeletonHelper = new THREE.SkeletonHelper( objectMesh );
      scene.add( skeletonHelper );
      
      // Add a box helper.
      boxHelper = new THREE.BoxHelper(object, new THREE.Color(0xFF0000));
		  scene.add(boxHelper);
      
      // Init the animation.
      initAnimation();
    },
    function ( progressEvent ) {},
    function ( e ) {
      alert("Error loading object: "+e.message);
    }
  );
}


// --- Animation --- //
var mixer, idleAction, walkAction, runAction;
var clock = new THREE.Clock();

function initAnimation() {
  // Initialize mixer and clip actions
  mixer = new THREE.AnimationMixer( objectMesh );
  //idleAction = mixer.clipAction( 'idle' );
  //walkAction = mixer.clipAction( 'walk' );
  runAction = mixer.clipAction( 'run' );
  runAction.play();
}

function render() {
  requestAnimationFrame( render );

  // Update the animation position.
  var delta = clock.getDelta();
  if (mixer) mixer.update( delta );

  // I've tried updating all porssible properties, but no luck.
  scene.updateMatrix();
  scene.updateMatrixWorld(true);
  object.updateMatrix();
  object.updateMatrixWorld(true);
  objectMesh.updateMatrix();
  objectMesh.updateMatrixWorld();
  objectMesh.updateMorphTargets();
  objectMesh.matrixWorldNeedsUpdate = true;
  objectMesh.geometry.computeBoundingBox();
  objectMesh.geometry.computeBoundingSphere();
  
  // Get the object's bounds.
  objectBox = new THREE.Box3();
	objectBox.setFromObject( object );
	objectBounds = new THREE.Vector3();
	objectBox.getSize(objectBounds);
  
  // Display the values on screen.
  info.innerHTML = "Object Bounding Box:<br />"+
    "- maxX: "+ objectBox.max.x +", "+
    "maxY: "+ objectBox.max.y +", "+
    "maxZ: "+ objectBox.max.z +"<br />"+
    "- minX: "+ objectBox.min.x +", "+
    "minY: "+ objectBox.min.y +", "+
    "minZ: "+ objectBox.min.z +"<br />"+
    "Mesh Bounding Box:<br />"+
    "- maxX: "+ objectMesh.geometry.boundingBox.max.x +", "+
    "maxY: "+ objectMesh.geometry.boundingBox.max.y +", "+
    "maxZ: "+ objectMesh.geometry.boundingBox.max.z +"<br />"+
    "- minX: "+ objectMesh.geometry.boundingBox.min.x +", "+
    "minY: "+ objectMesh.geometry.boundingBox.min.y +", "+
    "minZ: "+ objectMesh.geometry.boundingBox.min.z +"<br />"+
    "Mesh Bounding Sphere:<br />"+
    "- centerX: "+ objectMesh.geometry.boundingSphere.center.x +", "+
    "centerY: "+ objectMesh.geometry.boundingSphere.center.y +", "+
    "centerZ: "+ objectMesh.geometry.boundingSphere.center.z +"<br />"+
    "- radius: "+ objectMesh.geometry.boundingSphere.radius;
    
  // Update the box helper.
  if (boxHelper) boxHelper.update(object);

  // Render frame.
  renderer.render(scene, camera);
};

initObject();
render();
              
            
!
999px

Console