First pass at coordinate axes
This commit is contained in:
parent
413a8b5b81
commit
c7f2feab1f
1
Makefile
1
Makefile
@ -40,6 +40,7 @@ site/node_modules: node_modules package.json package-lock.json
|
|||||||
cp package.json package-lock.json tmpproj
|
cp package.json package-lock.json tmpproj
|
||||||
cd tmpproj && npm install --production
|
cd tmpproj && npm install --production
|
||||||
cp -r tmpproj/node_modules site
|
cp -r tmpproj/node_modules site
|
||||||
|
touch site/node_modules
|
||||||
|
|
||||||
dyna3.zip: $(BLDTARGS)
|
dyna3.zip: $(BLDTARGS)
|
||||||
zip -r $@ site
|
zip -r $@ site
|
||||||
|
@ -5,11 +5,37 @@ When you load dyna3, you should initially see a three-dimensional coordinate sys
|
|||||||
|
|
||||||
import {threeLoaded, three as J3} from './externals.js'
|
import {threeLoaded, three as J3} from './externals.js'
|
||||||
|
|
||||||
|
LTx = { dashed: true, plain: false }
|
||||||
|
|
||||||
|
buildAxis = (to, color, tx) ->
|
||||||
|
geom = new J3.Geometry()
|
||||||
|
if tx then mat = new J3.LineDashedMaterial(
|
||||||
|
{linewidth: 3, color, dashSize: 0.5, gapSize: 0.5})
|
||||||
|
else mat = new J3.LineBasicMaterial {linewidth:3, color}
|
||||||
|
geom.vertices.push(new J3.Vector3(0,0,0))
|
||||||
|
geom.vertices.push to.clone()
|
||||||
|
axis = new J3.Line geom, mat, J3.LineSegments
|
||||||
|
axis.computeLineDistances()
|
||||||
|
axis
|
||||||
|
|
||||||
|
axes = (length) ->
|
||||||
|
ax = new J3.Object3D()
|
||||||
|
dirs = [ new J3.Vector3(length, 0, 0),
|
||||||
|
new J3.Vector3(0, length, 0),
|
||||||
|
new J3.Vector3(0, 0, length) ]
|
||||||
|
cols = [ 0xFF0000, 0x00FF00, 0x0000FF ]
|
||||||
|
for i in [0, 1, 2]
|
||||||
|
ax.add buildAxis dirs[i], cols[i], LTx.plain
|
||||||
|
dirs[i].multiplyScalar(-1)
|
||||||
|
ax.add buildAxis dirs[i], cols[i], LTx.dashed
|
||||||
|
ax
|
||||||
|
|
||||||
main = ->
|
main = ->
|
||||||
renderer = new J3.WebGLRenderer()
|
renderer = new J3.WebGLRenderer()
|
||||||
rwd = window.innerWidth
|
rwd = window.innerWidth
|
||||||
rht = window.innerHeight
|
rht = window.innerHeight
|
||||||
renderer.setSize rwd, rht
|
renderer.setSize rwd, rht
|
||||||
|
renderer.setClearColor 0xeeeeee, 1.0
|
||||||
document.body.appendChild renderer.domElement
|
document.body.appendChild renderer.domElement
|
||||||
|
|
||||||
scene = new J3.Scene()
|
scene = new J3.Scene()
|
||||||
@ -17,6 +43,7 @@ When you load dyna3, you should initially see a three-dimensional coordinate sys
|
|||||||
material = new J3.MeshBasicMaterial {color: 0xff00ff}
|
material = new J3.MeshBasicMaterial {color: 0xff00ff}
|
||||||
ball = new J3.Mesh geometry, material
|
ball = new J3.Mesh geometry, material
|
||||||
scene.add ball
|
scene.add ball
|
||||||
|
scene.add axes 10
|
||||||
|
|
||||||
camera = new J3.PerspectiveCamera 75, rwd/rht, 0.1, 1000
|
camera = new J3.PerspectiveCamera 75, rwd/rht, 0.1, 1000
|
||||||
camera.position.z = 5
|
camera.position.z = 5
|
||||||
|
Loading…
Reference in New Issue
Block a user