var container;
var camera, scene, renderer;
var mouseX = 0,
mouseY = 0;
var windowHalfX = window.innerWidth / 2;
var windowHalfY = window.innerHeight / 2;
var object;
init();
animate();
function init() {
container = document.createElement('div');
document.body.appendChild(container);
camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 1, 2000);
camera.position.z = 9;
// scene
scene = new THREE.Scene();
var ambientLight = new THREE.AmbientLight(0xcccccc, 0.4);
scene.add(ambientLight);
var pointLight = new THREE.PointLight(0xffffff, 0.8);
camera.add(pointLight);
scene.add(camera);
var loader = new THREE.OBJLoader();
loader.load('https://tfoj-demo.s3.eu-west-2.amazonaws.com/signature-military-nologo.obj', function(object) {
////////////// code for THRAX
////////////// code for THRAX
let mesh = new THREE.Mesh(object.children[0].geometry);
mesh.material.side = THREE.DoubleSide;
scene.add(mesh);
const raycaster = new THREE.Raycaster();
const rayDirection = new THREE.Vector3(0,1,0).normalize(); // directions of raycaster
const rayOrigin = new THREE.Vector3(0.0001, -8.8, 0.00001); // starting point of Raycaster
let intersects = [];
raycaster.set(rayOrigin, rayDirection);
intersects = raycaster.intersectObject(mesh);
console.log(intersects.length);
////////////// NED code for THRAX
////////////// NED code for THRAX
////////////// NED code for THRAX
var box = new THREE.Box3().setFromObject(object);
var object3DWidth = box.max.x - box.min.x;
var object3DHeight = box.max.y - box.min.y;
var object3DDepth = box.max.z - box.min.z;
// position camera to fill view according to bounding box size
var size = Math.max(object3DHeight, object3DWidth);
var dist = size / 2 / Math.tan(Math.PI * 40 / 360);
camera.position.z = dist;
//comment out above line to see pre-zoomed view
});
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.