Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eturnity_3d_layout_viewer

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eturnity_3d_layout_viewer - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

config.js

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)
}
}

4

package.json
{
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc