How to build a perpendicular in three.js? - three.js

I need to build a perpendicular (line at an angle of 90 degrees to the original line) across the mid point of a straight line.
line = new THREE.Line( geometry, material );
geometry.vertices.push(
new THREE.Vector3( 100, 200, 0 ),
new THREE.Vector3( 300, 500, 0 ) );
In the manual I was not found information about it.
https://threejs.org/docs/#api/en/objects/Line
Thank you!

You can find the normal of a line by subtracting its start point from its end point (thus you'll get its direction), then rotate the resulted vector at 90 degrees (Math.PI * 0.5), then normalize it, and this is it, you've got the normal.
In the code snippet, the line itself is blueish (aqua), its normal is red.
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(60, window.innerWidth / window.innerHeight, 1, 1000);
camera.position.set(0, 0, 10);
var renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
var grid = new THREE.GridHelper(10, 10);
grid.rotation.x = -Math.PI * 0.5;
scene.add(grid);
var lineVertices = [
new THREE.Vector3(1, 2),
new THREE.Vector3(3, 5)
];
var lineGeom = new THREE.BufferGeometry().setFromPoints(lineVertices);
var lineMat = new THREE.LineBasicMaterial({color: 0x00ffff});
var line = new THREE.Line(lineGeom, lineMat);
scene.add(line);
var midPoint = new THREE.Vector3()
.subVectors(lineVertices[1], lineVertices[0])
.multiplyScalar(0.5)
.add(lineVertices[0]);
var normal = new THREE.Vector3()
.subVectors(lineVertices[1], lineVertices[0])
.applyAxisAngle(new THREE.Vector3(0, 0, 1), Math.PI * 0.5)
.normalize();
var normalVertices = [
normal.clone().setLength(2).add(midPoint),
normal.clone().negate().setLength(2).add(midPoint)
];
var normalGeom = new THREE.BufferGeometry().setFromPoints(normalVertices);
var normalMat = new THREE.LineBasicMaterial({color: 0xff0000 });
var normal = new THREE.Line(normalGeom, normalMat);
scene.add(normal);
renderer.setAnimationLoop(()=>{renderer.render(scene, camera)});
body {
overflow:hidden;
margin: 0;
}
<script src="https://threejs.org/build/three.min.js"></script>

Related

How to animate a threeJS object using GSAP?

I have been learning threeJS just recently and can't get passed a problem. I tried to animate a extruded triangle using the GSAP library. It is just a simple animation to have the triangle move to the right but it seems I did something wrong. Any help is much appreciated.
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(
75,
window.innerWidth / window.innerHeight,
0.1,
1000
);
const renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
// Create Triangles
var material = new THREE.MeshPhongMaterial({
color: 0xf6c12a,
shininess: 70
});
var shape = new THREE.Shape();
shape.moveTo(0, 0);
shape.lineTo(2, 3);
shape.lineTo(4, 0);
shape.lineTo(0, 0);
var extrudeSettings = {
steps: 5,
depth: 1,
bevelEnabled: true,
bevelThickness: 0.3,
bevelSize: 0.5,
bevelOffset: 0,
bevelSegments: 1
};
var geometry = new THREE.ExtrudeBufferGeometry(shape, extrudeSettings);
// Sets the origin to the center of geometry for rotation
geometry.center();
var mesh = new THREE.Mesh(geometry, material);
mesh.position.x = 0;
mesh.position.y = 0;
mesh.position.z = -5;
mesh.scale.set(1.5, 1.5, 1.5);
scene.add(mesh);
gsap.to(mesh, { duration: 2, x: 300 });
camera.position.z = 5;
// Background
var geometry = new THREE.PlaneGeometry(1000, 1000, 1);
var material = new THREE.MeshPhysicalMaterial({ color: 0x444444 });
var plane = new THREE.Mesh(geometry, material);
plane.position.z = -50;
scene.add(plane);
// Lighting
var ambientLight = new THREE.AmbientLight(0xffffff, 0.55);
scene.add(ambientLight);
var pointLight1 = new THREE.PointLight(0xf9eac8, 1, 100);
pointLight1.position.set(5, 10, 0);
pointLight1.castShadow = true;
pointLight1.shadow.camera.top = 20;
scene.add(pointLight1);
function render() {
requestAnimationFrame(render);
renderer.render(scene, camera);
}
render();
Here is the link to Codepen
Tried to put the gsap code into different position but maybe that's not the problem.
gsap.to(mesh.position, { duration: 2, x: 300 });
the value that you want to change is mesh.position.x not mesh.x
just add .position it will work

Connecting two components in Three.js

I would like to build something that allows the connection of two components, kind of like a guitar cable will plug into an amp from a guitar. So I want to connect to one point, and then drag the connection to a second point and have there be some natural hang in the rope. I made this example from a previous SO question (Three.js rope / cable effect - animating thick lines), but I can't seem to get the calculation right. So the question would be, how would I be able to make a function with this signature:
function drawSpline(startPoint, endPoint, ropeLength) {
// returns a new THREE.Line object with a natural curvature for "slack" in the rope between the two points
}
This is what I have so far:
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 );
scene.add(camera);
camera.position.z = 10;
const renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );
function animate() {
requestAnimationFrame( animate );
renderer.render( scene, camera );
}
animate();
const RADIUS = 1;
const SEGMENTS = 16;
const RINGS = 16;
const sphereMaterial =
new THREE.MeshLambertMaterial(
{
color: 0xCC0000
});
const sphere = new THREE.Mesh(
new THREE.SphereGeometry(
RADIUS,
SEGMENTS,
RINGS),
sphereMaterial);
sphere.position.z = 0;
const pointLight =
new THREE.PointLight(0xFFFFFF);
// set its position
pointLight.position.x = 10;
pointLight.position.y = 50;
pointLight.position.z = 130;
// add to the scene
scene.add(pointLight);
const shiftRatio = 7.5;
scene.add(drawSpline({x: 0, y: -3, z: 0}, {x: 6, y: 1, z: 0}, 'blue'));
function drawSpline(beginning, end, clr){
let ySign = Math.sign((end.y + beginning.y) / 2)
let appliedRatio = shiftRatio;
let midVector = new THREE.Vector3( (end.x + beginning.x) / 8, (end.y+beginning.y)/2, (end.z+beginning.z)/ 2 )
let positionVector = new THREE.Vector3(0,end.y-beginning.y,end.z-beginning.z)
let orthogVector = new THREE.Vector3(0,positionVector.z,-positionVector.y).normalize()
var curve = new THREE.CatmullRomCurve3( [
new THREE.Vector3( beginning.x, beginning.y, beginning.z ),
midVector.clone().addScaledVector(orthogVector,ySign*appliedRatio),
new THREE.Vector3( end.x, end.y, end.z ),
]);
var points = curve.getPoints( 20 );
console.log(points);
var geometry = (new THREE.BufferGeometry()).setFromPoints( points );
var material = new THREE.LineBasicMaterial( { color : clr } );
// Create the final object to add to the scene
var curveObject = new THREE.Line( geometry, material );
return curveObject;
}

I need to use the data from first picture to draw cylinder,put two cylinders point B is not coincide(like second picture)

**I need to use the data from first picture to draw cylinder,put two cylinders point B is not coincide(like second picture) **
var geometry = new THREE.CylinderGeometry(10, 10,151.02648774304458, 20, 1, false);
var mesh = new THREE.Mesh(geometry, material);
mesh.position.set(1,75.5,1);
scene.add(mesh);
var material1 = new THREE.MeshBasicMaterial({ color: 0xff0000 });
var geometry1 = new THREE.CylinderGeometry(10, 10,158.8741640418605, 20, 1, false);
var mesh1 = new THREE.Mesh(geometry1, material1);
mesh1.position.set(-30,217,32.5);
mesh1.rotation.set(2,151,2);
scene.add(mesh1);
You have to add the red cylinder to a Group. Set the position in that way, that the bottom of the cylinder is at (0, 0, 0). Set the position of the group in that way, that it's origin is at the top of the black cylinder.
Finally you have to rotate the group:
let height = 151.02648774304458;
let height1 = 158.8741640418605;
var geometry = new THREE.CylinderGeometry(10, 10, height, 20, 1, false);
var mesh = new THREE.Mesh(geometry, material);
mesh.position.set(1, 75.5, 1);
scene.add(mesh);
var material1 = new THREE.MeshBasicMaterial({ color: 0xff0000 });
var geometry1 = new THREE.CylinderGeometry(10, 10, height1, 20, 1, false);
var mesh1 = new THREE.Mesh(geometry1, material1);
mesh1.position.set(0, height1/2, 0);
group = new THREE.Group();
group.position.set(mesh.position.x, mesh.position.y + height/2, mesh.position.z);
group.add(mesh1);
group.rotation.set(...);
scene.add(group);
(function onLoad() {
var container, camera, scene, renderer, orbitControls;
init();
animate();
function init() {
container = document.getElementById('container');
renderer = new THREE.WebGLRenderer({
canvas: my_canvas,
antialias: true,
alpha: true
});
renderer.setPixelRatio(window.devicePixelRatio);
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.shadowMap.enabled = true;
//container.appendChild(renderer.domElement);
camera = new THREE.PerspectiveCamera(70, window.innerWidth / window.innerHeight, 1, 10000);
camera.position.set(0, 200, -400);
camera.lookAt( 0, 0, 0 );
scene = new THREE.Scene();
scene.background = new THREE.Color(0xffffff);
scene.add(camera);
window.onresize = function() {
renderer.setSize(window.innerWidth, window.innerHeight);
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
}
orbitControls = new THREE.OrbitControls(camera, container);
createModel();
}
var group;
function createModel() {
var material = new THREE.MeshPhongMaterial({color:'#ff0000'});
var material1 = new THREE.MeshPhongMaterial({color:'#000000'});
let height = 151.02648774304458;
let height1 = 158.8741640418605;
var geometry = new THREE.CylinderGeometry(10, 10, height, 20, 1, false);
var mesh = new THREE.Mesh(geometry, material);
mesh.position.set(1, 75.5, 1);
scene.add(mesh);
var material1 = new THREE.MeshBasicMaterial({ color: 0xff0000 });
var geometry1 = new THREE.CylinderGeometry(10, 10, height1, 20, 1, false);
var mesh1 = new THREE.Mesh(geometry1, material1);
mesh1.position.set(0, height1/2, 0);
group = new THREE.Group();
group.position.set(mesh.position.x, mesh.position.y + height/2, mesh.position.z);
group.add(mesh1);
//group.rotation.set(2, 151, 2);
scene.add(group);
}
var rotate = 0.0;
function animate() {
group.rotation.set(0, 0, rotate);
rotate += 0.01;
requestAnimationFrame(animate);
orbitControls.update();
render();
}
function render() {
renderer.render(scene, camera);
}
})();
<script src="https://cdn.jsdelivr.net/npm/three#0.115/build/three.js"></script>
<script src="https://cdn.jsdelivr.net/npm/three#0.115/examples/js/controls/OrbitControls.js"></script>
<div id="container"><canvas id="my_canvas"> </canvas></div>
To set a specific rotation by a specific vector, I recommend to set the rotation by a .setRotationFromQuaternion.
The Quaternion defines how to rotate from the upwards direction (0, 1, 0) to the target direction. The Target direction is the vector form the joint to the endpoint of the upper cylinder (-62-1, 283-151, 61-1):
For instance:
let upVector = new THREE.Vector3(0, 1, 0);
let targetVector = new THREE.Vector3(-62 - 1, 283 - height, 61 - 1);
let quaternion = new THREE.Quaternion().setFromUnitVectors(
upVector, targetVector.normalize());
group.setRotationFromQuaternion(quaternion)

ThreeJS: How to clone the rotation of one object to another

I have two canvas where two canvas has two different objects. I'm trying to set the rotation of one object to another. Here the second canvas object acts as a viewcube where it should only rotate when the object_1 gets rotated.
I have tried by set the rotation of the one camera to another but I can't seem to achieve it.
Here's the fiddle link https://jsfiddle.net/jvy396x8/2/
var cube = document.querySelector('.cube');
// var container = document.getElementById('container');
var scene_1Rotation;
var scene = new THREE.Scene();
var scene_1 = new THREE.Scene();
var object;
var w = window.innerWidth;
var h = window.innerHeight;
var viewSize = h;
var aspectRatio = w / h;
_viewport = {
viewSize: viewSize,
aspectRatio: aspectRatio,
left: (-aspectRatio * viewSize) / 2,
right: (aspectRatio * viewSize) / 2,
top: viewSize / 2,
bottom: -viewSize / 2,
near: -10000,
far: 10000
}
var camera = new THREE.OrthographicCamera(
_viewport.left,
_viewport.right,
_viewport.top,
_viewport.bottom,
_viewport.near,
_viewport.far
);
camera.zoom = 25;
var camera_1 = new THREE.PerspectiveCamera(100, window.innerWidth / window.innerHeight, 0.001, 1000000);
// var camera = new THREE.OrthographicCamera(window.innerWidth / -30, window.innerWidth / 30, window.innerHeight / 30, window.innerHeight / -30, 1, 1000)
camera.position.set(20, 0, 0);
var renderer = new THREE.WebGLRenderer({
antialias: true
});
var renderer_1 = new THREE.WebGLRenderer({
antialias: true
});
$('#container').append(renderer_1.domElement);
$('#scene').html(renderer_1.domElement);
// var zoom = orthoWidth / meshWidth;
// _Camera.setZoom(zoom);
object = new THREE.Group();
scene.background = new THREE.Color(0xffffff0);
console.log(scene);
scene_1.background = new THREE.Color(0xffffff);
console.log(scene_1);
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
var controls = new THREE.OrbitControls(camera, renderer.domElement);
var controls_1 = new THREE.OrbitControls(camera_1, renderer_1.domElement);
var geometry_1 = new THREE.BoxGeometry();
var material_1 = new THREE.MeshBasicMaterial({ color: 0x00ff00 });
var cube_1 = new THREE.Mesh(geometry_1, material_1);
scene_1.add(cube_1);
var geometry_2 = new THREE.BoxGeometry();
var material_2 = new THREE.MeshBasicMaterial({ color: 0x00fff0 });
var cube_2 = new THREE.Mesh(geometry_2, material_2);
cube_2.position.x = 1;
scene_1.add(cube_2);
controls_1.noPan = true;
controls_1.noZoom = true;
camera_1.position.z = 2;
var material = new THREE.LineBasicMaterial({
color: 0x0000ff
});
var geometry = new THREE.Geometry();
geometry.vertices.push(
new THREE.Vector3(0, 0, 0),
new THREE.Vector3(0, 7, 0),
new THREE.Vector3(0, 0, 0)
);
var line = new THREE.Line(geometry, material);
object.add(line)
scene.add(object);
var material = new THREE.LineBasicMaterial({
color: 0xcc0000
});
var geometry = new THREE.Geometry();
geometry.vertices.push(
new THREE.Vector3(0, 0, 0),
new THREE.Vector3(0, 0, 0),
new THREE.Vector3(7, 0, 0)
);
var line = new THREE.Line(geometry, material);
object.add(line)
scene.add(object);
var material = new THREE.LineBasicMaterial({
color: 0x008900
});
var geometry = new THREE.Geometry();
geometry.vertices.push(
new THREE.Vector3(0, 0, 7),
new THREE.Vector3(0, 0, 0),
new THREE.Vector3(0, 0, 0)
);
var line = new THREE.Line(geometry, material);
object.add(line)
scene.add(object);
// ' X ' AXIS dashed material |
var xPlaneDashedMaterial = new THREE.LineDashedMaterial({ color: 0x00008b, dashSize: Math.PI * 2 / 20, gapSize: Math.PI * 2 / 20, linewidth: 10 }),
xPlaneDashedCircleGeometry = new THREE.CircleGeometry(7, 75, 69.9, 5);
xPlaneDashedCircleGeometry.vertices.shift();
var xPlaneDashedGeomtry = new THREE.Line(xPlaneDashedCircleGeometry, xPlaneDashedMaterial);
xPlaneDashedGeomtry.computeLineDistances();
object.add(xPlaneDashedGeomtry)
scene.add(object);
var xPlanePlainMaterial = new THREE.MeshBasicMaterial({ color: 0x00008b });
var xplanePlainCirleGeometry = new THREE.CircleGeometry(7, 75, 18.3, 1.3);
xplanePlainCirleGeometry.vertices.shift();
var xPlanePlainGeomtry = new THREE.Line(xplanePlainCirleGeometry, xPlanePlainMaterial);
object.add(xPlanePlainGeomtry)
scene.add(object);
// ' Y ' AXIS dashed material -
var yPlaneDashedMaterial = new THREE.LineDashedMaterial({ color: 0xcc0000, dashSize: Math.PI * 2 / 20, gapSize: 1 * Math.PI * 2 / 20, linewidth: 10 });
var yPlaneDashedCircleGeometry = new THREE.CircleGeometry(7, 30, 7., 4.8);
yPlaneDashedCircleGeometry.vertices.shift();
var yPlaneDashedGeomtry = new THREE.Line(yPlaneDashedCircleGeometry, yPlaneDashedMaterial);
yPlaneDashedGeomtry.computeLineDistances();
yPlaneDashedGeomtry.rotation.x = 17.27;
object.add(yPlaneDashedGeomtry)
scene.add(object);
var yPlanePlainMaterial = new THREE.MeshBasicMaterial({ color: 0xcc0000 });
var yPlanePlainCirleGeometry = new THREE.CircleGeometry(7, 75, 18.1, 1.5);
yPlanePlainCirleGeometry.vertices.shift();
var yPlanePlainGeomtry = new THREE.Line(yPlanePlainCirleGeometry, yPlanePlainMaterial);
yPlanePlainGeomtry.rotation.x = 17.27;
object.add(yPlanePlainGeomtry)
scene.add(object);
// ' Z ' AXIS material /
var zPlanePlainMaterial = new THREE.LineDashedMaterial({ color: 0x008900, dashSize: 1 * Math.PI * 4 / 40, gapSize: 1 * Math.PI * 4 / 40, linewidth: 10 });
var zPlanePlainCirleGeometry = new THREE.CircleGeometry(7, 75, 69.9, 10);
zPlanePlainCirleGeometry.vertices.shift();
var zPlanePlainGeomtry = new THREE.Line(zPlanePlainCirleGeometry, zPlanePlainMaterial);
zPlanePlainGeomtry.computeLineDistances();
zPlanePlainGeomtry.rotation.y = 17.27;
object.add(zPlanePlainGeomtry)
scene.add(object);
// ' X 'CONE geomtry|
var xPlaneConeGeometry = new THREE.ConeGeometry(0.2, 1, 32);
var xPlaneConeGeomtryMaterial = new THREE.MeshBasicMaterial({ color: 0x00008b });
var xPlaneConeGeometryLeft = new THREE.Mesh(xPlaneConeGeometry, xPlaneConeGeomtryMaterial);
object.add(xPlaneConeGeometryLeft)
scene.add(object);
//' X ' CONE
xPlaneConeGeometryLeft.position.y = 6.5;
//' Y 'CONE geomtry
var yPlaneConeGeometry = new THREE.ConeGeometry(0.2, 1, 32);
var yPlaneConeGeomtryMaterial = new THREE.MeshBasicMaterial({ color: 0xcc0000 });
var zPlaneConeGeometry = new THREE.ConeGeometry(0.2, 1, 32);
var zPlaneConeGeomtryMaterial = new THREE.MeshBasicMaterial({ color: 0x008900 });
var yPlaneConeGeometryLeft = new THREE.Mesh(yPlaneConeGeometry, yPlaneConeGeomtryMaterial);
object.add(yPlaneConeGeometryLeft);
scene.add(object);
var zPlaneConeGeometryRight = new THREE.Mesh(zPlaneConeGeometry, zPlaneConeGeomtryMaterial);
object.add(zPlaneConeGeometryRight)
scene.add(object);
console.log("object");
console.log(object.children.rotation);
// ' Y ' CONE
yPlaneConeGeometryLeft.position.x = 6.5;
yPlaneConeGeometryLeft.rotation.z = 4.7;
zPlaneConeGeometryRight.position.z = 6.5;
zPlaneConeGeometryRight.rotation.x = 1.6;
var mat = new THREE.Matrix4();
renderer_1.setAnimationLoop(() => {
mat.extractRotation(camera_1.matrixWorldInverse);
renderer_1.render(scene_1, camera_1);
camera_1.updateProjectionMatrix();
});
renderer.setAnimationLoop(() => {
mat.extractRotation(camera.matrixWorldInverse);
renderer.render(scene, camera);
camera.updateProjectionMatrix();
});
I have tried by set the rotation of the one camera to another by I can't able to achieve it.
To replicate the intended behavior in the second scene, it's not sufficient to just copy the rotation. Orbiting also transforms the position of the camera. Hence I suggest that you use a single camera for both scenes.
Also note that it's not necessary to update the projection matrix of your camera per frame. In your use case, do it once right after changing the zoom property.
Updated fiddle: https://jsfiddle.net/s0wzdm32/1/

Three js: Create a vertical ruler with measurements

I want to create a vertical ruler with measurements like the image below. can anyone help me with it.
var material = new THREE.LineBasicMaterial({
color: 0x07E1E1,
linewidth: 3
});
var geometry = new THREE.Geometry();
geometry.vertices.push(
new THREE.Vector3( 0, 0, 0 ),
new THREE.Vector3( 0, 1100, 0 ),
new THREE.Vector3( 0, 0, 0 )
);
var line = new THREE.Line( geometry, material );
scene.add( line );
line.position.set(-550, -550, 200);
But it is not getting as the image and also the measurements…
You can use LineBasicMaterial and Line elements.
var camera, scene, renderer, object;
init();
function init() {
var container;
container = document.getElementById( 'container' );
camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 1, 1100 );
camera.target = new THREE.Vector3( 0, 0, 0 );
scene = new THREE.Scene();
object = new THREE.Object3D();
var lineMtr = new THREE.LineBasicMaterial({ color: 0xffffff, linewidth: 3, opacity: 1 });
var geo = new THREE.Geometry();
geo.vertices.push(new THREE.Vector3(0, 10 ,3));
geo.vertices.push(new THREE.Vector3(0, 0 ,3));
var line = new THREE.Line(geo, lineMtr);
var i = 0, l = 10;
object.add(line);
while (i <= l) {
var geoSegm = new THREE.Geometry();
geoSegm.vertices.push(new THREE.Vector3(0.1, i, 3));
geoSegm.vertices.push(new THREE.Vector3(0, i, 3));
var lineSegm = new THREE.Line(geoSegm, lineMtr);
object.add(lineSegm);
var textSprite = makeTextSprite((i * 10).toString(), {r: 255, g: 255, b: 255, a: 255}, new THREE.Vector3(0.2, i, 3), Math.PI);
object.add(textSprite);
i++;
}
renderer = new THREE.WebGLRenderer();
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
}
function animate() {
requestAnimationFrame( animate );
renderer.render( scene, camera );
}
You can create a texture for a SpriteMaterial, then use Sprite for ruler texts.
function makeTextSprite(label, fontColor, pos, rot) {
var fontface = "Arial";
var fontsize = 100;
var canvas = document.createElement('canvas');
var context = canvas.getContext('2d');
context.font = "Bold " + fontsize.toString() + "px " + fontface;
var metrics = context.measureText(label);
context.rotate(-Math.PI);
context.translate(-canvas.width, -canvas.height);
context.fillStyle = "rgba(" + fontColor.r + "," + fontColor.g + "," + fontColor.b + "," + fontColor.a + ")";
context.fillText(label, 0, 100);
var texture = new THREE.Texture(canvas);
texture.needsUpdate = true;
texture.center = new THREE.Vector2(0.5, 0.5);
texture.rotation = Math.PI;
var spriteMaterial = new THREE.SpriteMaterial({
map: texture, color: 0xffffff
});
var sprite = new THREE.Sprite(spriteMaterial);
sprite.scale.set(0.25, 0.25, 0.25);
sprite.position.set(pos.x, pos.y, pos.z);
return sprite;
}
I used codes in that link http://jsfiddle.net/3mrzL75h/19/
In first look you can't seeing ruler, drag camera to right.

Resources