eturnity_3d_layout_viewer
Advanced tools
Comparing version 1.0.1 to 1.0.2
129
index.js
@@ -1,3 +0,126 @@ | ||
function test(){ | ||
console.log('it works') | ||
} | ||
import * as THREE from 'three' | ||
import TWEEN from 'tween' | ||
import { addVector,multiplyVector } from '@/views/three-d-layout/utils/maths' | ||
import { initialiseThree } from './helper/threeInitialisation' | ||
import { material } from './helper/materials' | ||
import renderMixin from './helper/renderMixin' | ||
export const class ThreeDLayoutRenderer { | ||
constructor(){ | ||
console.log('Im in') | ||
this={ | ||
scene: new THREE.Scene(), | ||
camera: new THREE.PerspectiveCamera(50, 300 / 300, 0.1, 100000), | ||
cameraprojection: null, | ||
texture: null, | ||
material: material, | ||
renderer: new THREE.WebGLRenderer({ antialias: true,preserveDrawingBuffer: true}), | ||
orbitControl:null, | ||
raycaster:new THREE.Raycaster(), | ||
loader : new THREE.TextureLoader(), | ||
pointer:{x:0,y:0}, | ||
canvasHeight:null, | ||
canvasWidth:null, | ||
canvasOffset:{x:0,y:0}, | ||
tweenCamera:null, | ||
tweenOrbit:null, | ||
three_map:null, | ||
polygons: [], | ||
edges: [], | ||
nodes: [], | ||
imageMap: [], | ||
mapConfig: [], | ||
selectedLayer: 'roof', | ||
selectedRoof: null, | ||
} | ||
console.log('here is initial state:',this) | ||
this.mounted() | ||
console.log('after mount',this) | ||
} | ||
mounted() { | ||
this.initialiseThree() | ||
this.loadProjectionMaterial() | ||
this.renderGeometry() | ||
this.onWindowResize() | ||
this.animate() | ||
this.$root.$on('on-roofSelected',(polygon)=>this.setCameraOrthogonalTo(polygon)) | ||
}, | ||
initialiseThree, | ||
setCameraOrthogonalTo(polygon){ | ||
if(polygon){ | ||
let polygonRef=polygon | ||
const targetVector=polygonRef.meanPoint | ||
const target=[targetVector.x/1000,targetVector.y/1000,targetVector.z/1000] | ||
const positionVector=addVector(polygonRef.meanPoint,multiplyVector(45000,polygonRef.normalVector)) | ||
const position=[(positionVector.x/1000),(positionVector.y/1000)-1,positionVector.z/1000] | ||
} | ||
}, | ||
getCanvasOffset(){ | ||
if(!this.$refs.canvas3DContainer) return { top: 0, left: 0 } | ||
var box = this.$refs.canvas3DContainer.getBoundingClientRect() | ||
var body = document.body | ||
var docEl = document.documentElement; | ||
var scrollTop = window.pageYOffset || docEl.scrollTop || body.scrollTop | ||
var scrollLeft = window.pageXOffset || docEl.scrollLeft || body.scrollLeft | ||
var clientTop = docEl.clientTop || body.clientTop || 0 | ||
var clientLeft = docEl.clientLeft || body.clientLeft || 0 | ||
var top = box.top + scrollTop - clientTop | ||
var left = box.left + scrollLeft - clientLeft | ||
return { top: Math.round(top), left: Math.round(left) } | ||
}, | ||
onWindowResize() { | ||
this.camera.aspect = window.innerWidth / window.innerHeight | ||
this.camera.updateProjectionMatrix() | ||
this.canvasOffset=this.getCanvasOffset() | ||
this.canvasHeight = this.$refs.canvas3DContainer.clientHeight | ||
this.canvasWidth = this.$refs.canvas3DContainer.clientWidth | ||
this.resizeCanvasToDisplaySize() | ||
//this.renderer.setSize(window.innerWidth / 2, window.innerHeight / 2) | ||
}, | ||
resizeCanvasToDisplaySize() { | ||
const canvas = this.renderer.domElement | ||
// look up the size the canvas is being displayed | ||
const width = canvas.clientWidth | ||
const height = canvas.clientHeight | ||
// adjust displayBuffer size to match | ||
if (canvas.width !== width || canvas.height !== height) { | ||
// you must pass false here or three.js sadly fights the browser | ||
this.renderer.setSize(width, height, false) | ||
this.renderer.setViewport(0,0,width, height) | ||
this.camera.aspect = width / height | ||
this.camera.updateProjectionMatrix() | ||
// update any render target sizes here | ||
} | ||
}, | ||
animate() { | ||
this.render() | ||
requestAnimationFrame(this.animate) | ||
}, | ||
render() { | ||
this.renderer.clear(); | ||
this.renderer.render(this.scene, this.camera) | ||
} | ||
} | ||
{ | ||
"name": "eturnity_3d_layout_viewer", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "standalone 3d layout viewer", | ||
@@ -12,2 +12,4 @@ "main": "index.js", | ||
"dependencies": { | ||
"earcut": "^2.2.4", | ||
"geo-three": "^0.1.11", | ||
"three": "^0.148.0", | ||
@@ -14,0 +16,0 @@ "three-projected-material": "^2.1.2" |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
137744
17
3853
4
+ Addedearcut@^2.2.4
+ Addedgeo-three@^0.1.11
+ Addedearcut@2.2.4(transitive)
+ Addedgeo-three@0.1.15(transitive)