Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mods
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
mods
Commits
8d91c844
Commit
8d91c844
authored
Oct 23, 2019
by
Neil Gershenfeld
Browse files
Options
Downloads
Patches
Plain Diff
finally fixed 3D view flipping
parent
2e74ac56
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/path/view
+4
-173
4 additions, 173 deletions
modules/path/view
with
4 additions
and
173 deletions
modules/path/view
+
4
−
173
View file @
8d91c844
...
...
@@ -358,7 +358,10 @@ function init_window() {
camera.position.x = mod.x0+Math.sin(mod.thetaz)*mod.r*Math.sin(mod.thetaxy)
camera.position.y = mod.y0+Math.cos(mod.thetaz)*mod.r*Math.sin(mod.thetaxy)
camera.position.z = mod.r*Math.cos(mod.thetaxy)
if (Math.cos(mod.thetaxy) > 0)
camera.up = new THREE.Vector3(Math.sin(mod.thetaz),Math.cos(mod.thetaz),0)
else
camera.up = new THREE.Vector3(-Math.sin(mod.thetaz),-Math.cos(mod.thetaz),0)
camera.lookAt(new THREE.Vector3(mod.x0,mod.y0,0))
camera.updateProjectionMatrix()
renderer.render(scene,camera)
...
...
@@ -381,178 +384,6 @@ function init_window() {
}
}
//
// old_open_view_window
//
function old_open_view_window() {
//
// globals
//
var container,scene,camera,renderer,win,controls
//
// open the window
//
open_window()
//
// open_window
//
function open_window() {
//
// open window
//
win = window.open('')
mod.win = win
//
// load three.js
//
var script = document.createElement('script')
script.type = 'text/javascript'
script.onload = init_window
script.src = 'js/three.js/three.min.js'
mod.div.appendChild(script)
}
//
// init_window
//
function init_window() {
//
// close button
//
var btn = document.createElement('button')
btn.appendChild(document.createTextNode('close'))
btn.style.padding = mods.ui.padding
btn.style.margin = 1
btn.addEventListener('click',function(){
win.close()
mod.win = undefined
})
win.document.body.appendChild(btn)
//
// label text
//
var text = win.document.createTextNode(' left: pan, right: rotate, scroll: zoom')
win.document.body.appendChild(text)
//
// GL container
//
win.document.body.appendChild(document.createElement('br'))
container = win.document.createElement('div')
container.style.overflow = 'hidden'
win.document.body.appendChild(container)
//
// event handlers
//
container.addEventListener('contextmenu',context_menu)
container.addEventListener('mousedown',mouse_down)
container.addEventListener('mouseup',mouse_up)
container.addEventListener('mousemove',mouse_move)
container.addEventListener('wheel',mouse_wheel)
//
// add scene
//
scene = new THREE.Scene()
mod.scene = scene
var width = win.innerWidth
var height = win.innerHeight
var aspect = width/height
var near = 0.1
var far = 1000000
camera = new THREE.PerspectiveCamera(90,aspect,near,far)
mod.camera = camera
scene.add(camera)
//
// add renderer
//
renderer = new THREE.WebGLRenderer({antialias:true})
mod.renderer = renderer
renderer.setClearColor(0xffffff)
renderer.setSize(width,height)
container.appendChild(renderer.domElement)
//
// show the path if available
//
show_path()
}
//
// context_menu
//
function context_menu(evt) {
evt.preventDefault()
evt.stopPropagation()
return (false)
}
//
// mouse_down
//
function mouse_down(evt) {
evt.preventDefault()
evt.stopPropagation()
mod.button = evt.button
mod.x = evt.clientX
mod.y = evt.clientY
}
//
// mouse_up
//
function mouse_up(evt) {
mod.button = undefined
mod.x = evt.clientX
mod.y = evt.clientY
}
//
// mouse_move
//
function mouse_move(evt) {
evt.preventDefault()
evt.stopPropagation()
var dx = evt.clientX-mod.x
var dy = evt.clientY-mod.y
mod.x = evt.clientX
mod.y = evt.clientY
if (mod.button == 0) {
mod.x0 +=
Math.sin(mod.thetaz)*mod.height*dy/win.innerHeight
-Math.cos(mod.thetaz)*mod.width*dx/win.innerWidth
mod.y0 +=
Math.cos(mod.thetaz)*mod.height*dy/win.innerHeight
+Math.sin(mod.thetaz)*mod.width*dx/win.innerWidth
camera.position.x = mod.x0+Math.sin(mod.thetaz)*mod.r*Math.sin(mod.thetaxy)
camera.position.y = mod.y0+Math.cos(mod.thetaz)*mod.r*Math.sin(mod.thetaxy)
camera.position.z = mod.r*Math.cos(mod.thetaxy)
camera.position.z = mod.r*Math.cos(mod.thetaxy)
camera.up = new THREE.Vector3(Math.sin(mod.thetaz),Math.cos(mod.thetaz),0)
camera.lookAt(new THREE.Vector3(mod.x0,mod.y0,0))
camera.updateProjectionMatrix()
renderer.render(scene,camera)
}
else if (mod.button == 2) {
mod.thetaxy += dy/win.innerHeight
mod.thetaz += dx/win.innerWidth
camera.position.x = mod.x0+Math.sin(mod.thetaz)*mod.r*Math.sin(mod.thetaxy)
camera.position.y = mod.y0+Math.cos(mod.thetaz)*mod.r*Math.sin(mod.thetaxy)
camera.position.z = mod.r*Math.cos(mod.thetaxy)
camera.up = new THREE.Vector3(Math.sin(mod.thetaz),Math.cos(mod.thetaz),0)
camera.lookAt(new THREE.Vector3(mod.x0,mod.y0,0))
camera.updateProjectionMatrix()
renderer.render(scene,camera)
}
}
//
// mouse_wheel
//
function mouse_wheel(evt) {
evt.preventDefault()
evt.stopPropagation()
var dy = evt.deltaY/win.innerHeight
mod.r += mod.height*dy
camera.position.x = mod.x0+Math.sin(mod.thetaz)*mod.r*Math.sin(mod.thetaxy)
camera.position.y = mod.y0+Math.cos(mod.thetaz)*mod.r*Math.sin(mod.thetaxy)
camera.position.z = mod.r*Math.cos(mod.thetaxy)
camera.lookAt(new THREE.Vector3(mod.x0,mod.y0,0))
camera.updateProjectionMatrix()
renderer.render(scene,camera)
}
}
//
// return values
//
return ({
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment