get CSG to work
This commit is contained in:
Generated
+5
@@ -13904,6 +13904,11 @@
|
|||||||
"resolved": "https://registry.npmjs.org/three/-/three-0.77.0.tgz",
|
"resolved": "https://registry.npmjs.org/three/-/three-0.77.0.tgz",
|
||||||
"integrity": "sha1-iwsbAAR2ic6qAg1IClYspg2H/zc="
|
"integrity": "sha1-iwsbAAR2ic6qAg1IClYspg2H/zc="
|
||||||
},
|
},
|
||||||
|
"three-js-csg-es6": {
|
||||||
|
"version": "73.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/three-js-csg-es6/-/three-js-csg-es6-73.0.0.tgz",
|
||||||
|
"integrity": "sha512-eeXGyvRVKlfsfqUxuc8V1rIynDkXgEHXqFxQvdyOY2XVOT0ZdoSwQQEzNXUJrLiOUSXC3UaHqhA3P3bfDGL1Qw=="
|
||||||
|
},
|
||||||
"three.js": {
|
"three.js": {
|
||||||
"version": "0.77.1",
|
"version": "0.77.1",
|
||||||
"resolved": "https://registry.npmjs.org/three.js/-/three.js-0.77.1.tgz",
|
"resolved": "https://registry.npmjs.org/three.js/-/three.js-0.77.1.tgz",
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
"axios": "^0.18.1",
|
"axios": "^0.18.1",
|
||||||
"dat.gui": "^0.7.7",
|
"dat.gui": "^0.7.7",
|
||||||
"oimo": "^1.0.9",
|
"oimo": "^1.0.9",
|
||||||
|
"three-js-csg-es6": "^73.0.0",
|
||||||
"three.js": "^0.77.1",
|
"three.js": "^0.77.1",
|
||||||
"vue": "^2.6.11",
|
"vue": "^2.6.11",
|
||||||
"vue-meta": "^1.6.0",
|
"vue-meta": "^1.6.0",
|
||||||
|
|||||||
+1
-1
@@ -188,7 +188,7 @@ export default {
|
|||||||
// cam_controls: null,
|
// cam_controls: null,
|
||||||
init_cam_pos: { x: 0, y: 10, z: 100 },
|
init_cam_pos: { x: 0, y: 10, z: 100 },
|
||||||
// init_cam_pos: { x: 0, y: 150, z: 0 },
|
// init_cam_pos: { x: 0, y: 150, z: 0 },
|
||||||
// init_cam_rot: { x: this.deg2rad(180), y: 0, z: 0 },
|
init_cam_rot: { x: this.deg2rad(180), y: 0, z: 0 },
|
||||||
raycaster: new THREE.Raycaster(),
|
raycaster: new THREE.Raycaster(),
|
||||||
interactive_objects_names: ['Project', 'Content'],
|
interactive_objects_names: ['Project', 'Content'],
|
||||||
interactive_objects: [],
|
interactive_objects: [],
|
||||||
|
|||||||
@@ -1,11 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<mesh ref="block3d" name="Project" :position="position">
|
<object3d ref="block3d" name="Project" :obj="building" :position="position"/>
|
||||||
<!-- <geometry type="Box" :args="[size.x, size.y, size.z]" /> -->
|
|
||||||
<material type="MeshLambert" :color="color" :options="block_opts">
|
|
||||||
<!-- <texture :options="label_texture_opts" /> -->
|
|
||||||
</material>
|
|
||||||
</mesh>
|
|
||||||
<mesh ref="label3d" name="Label" :position="label_position">
|
<mesh ref="label3d" name="Label" :position="label_position">
|
||||||
<geometry type="Plane" :args="[label_size.x, label_size.y]" />
|
<geometry type="Plane" :args="[label_size.x, label_size.y]" />
|
||||||
<material type="MeshLambert" :options="label_opts">
|
<material type="MeshLambert" :options="label_opts">
|
||||||
@@ -43,7 +38,8 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import * as THREE from 'three'
|
import * as THREE from 'three'
|
||||||
// import { Base } from 'vue-threejs'
|
// import { toCSG, fromCSG } from 'three-csg'
|
||||||
|
import { ThreeBSP } from 'three-js-csg-es6'
|
||||||
|
|
||||||
import mixins from 'components/mixins'
|
import mixins from 'components/mixins'
|
||||||
import ContentBlock from 'components/objects/ContentBlock'
|
import ContentBlock from 'components/objects/ContentBlock'
|
||||||
@@ -62,17 +58,50 @@ export default {
|
|||||||
let size = { ...this.data.size }
|
let size = { ...this.data.size }
|
||||||
let position = { ...this.data.position }
|
let position = { ...this.data.position }
|
||||||
|
|
||||||
let geometry = new THREE.BoxBufferGeometry(size.x, size.y, size.z)
|
let materialOpts = {
|
||||||
|
color: 0xffffff,
|
||||||
|
side: THREE.DoubleSide
|
||||||
|
// wireframe: true,
|
||||||
|
// transparent: true,
|
||||||
|
// opacity: 0.6
|
||||||
|
// renderOrder: 0
|
||||||
|
}
|
||||||
|
let material = new THREE.MeshLambertMaterial(materialOpts)
|
||||||
|
|
||||||
|
// http://learningthreejs.com/blog/2011/12/10/constructive-solid-geometry-with-csg-js/
|
||||||
|
console.log('ThreeBSP', ThreeBSP)
|
||||||
|
|
||||||
|
let boxGeom = new THREE.BoxGeometry(size.x, size.y, size.z)
|
||||||
|
let boxMesh = new THREE.Mesh(boxGeom)
|
||||||
|
let boxBSP = new ThreeBSP(boxMesh)
|
||||||
|
console.log('boxBSP', boxBSP)
|
||||||
|
|
||||||
|
let holeGeom = new THREE.BoxGeometry(1000, 5, 5)
|
||||||
|
let holeMesh = new THREE.Mesh(holeGeom)
|
||||||
|
holeMesh.position.y = 50
|
||||||
|
let holeBSP = new ThreeBSP(holeMesh)
|
||||||
|
|
||||||
|
let buildingBSP = boxBSP.subtract(holeBSP)
|
||||||
|
console.log('buildingBSP', buildingBSP)
|
||||||
|
|
||||||
|
let building = buildingBSP.toMesh()
|
||||||
|
building.material = material
|
||||||
|
// building.geometry.computeVertexNormals()
|
||||||
|
|
||||||
|
// let buildingGeom = fromCSG(boxCSG)
|
||||||
|
// buildingGeom.computeVertexNormals()
|
||||||
|
|
||||||
|
// result
|
||||||
|
// let subtractCSG = boxMeshCSG.subtract(holeMeshCSG)
|
||||||
|
// let building = fromCSG(boxMeshCSG) // converting CSG back into ThreeJS object
|
||||||
|
//
|
||||||
|
// building.positon = position
|
||||||
|
// building.castShadow = true
|
||||||
|
// building.receiveShadow = true
|
||||||
|
|
||||||
return {
|
return {
|
||||||
block3d: null,
|
block3d: null,
|
||||||
block_opts: {
|
// block_opts: materialOpts,
|
||||||
side: THREE.DoubleSide
|
|
||||||
// wireframe: true,
|
|
||||||
// transparent: true,
|
|
||||||
// opacity: 0.6
|
|
||||||
// renderOrder: 0
|
|
||||||
},
|
|
||||||
label3d: null,
|
label3d: null,
|
||||||
label_opts: {
|
label_opts: {
|
||||||
side: THREE.DoubleSide,
|
side: THREE.DoubleSide,
|
||||||
@@ -84,7 +113,8 @@ export default {
|
|||||||
// size and positions are defined in store project
|
// size and positions are defined in store project
|
||||||
size: size,
|
size: size,
|
||||||
position: position,
|
position: position,
|
||||||
geometry: geometry,
|
// geometry: geometry,
|
||||||
|
building: building,
|
||||||
label_position: { x: 0, y: 0, z: 0 },
|
label_position: { x: 0, y: 0, z: 0 },
|
||||||
color: 0xffffff,
|
color: 0xffffff,
|
||||||
label_canvas: null,
|
label_canvas: null,
|
||||||
@@ -112,13 +142,10 @@ export default {
|
|||||||
// console.log('this.label_canvas', this.label_canvas)
|
// console.log('this.label_canvas', this.label_canvas)
|
||||||
},
|
},
|
||||||
mounted () {
|
mounted () {
|
||||||
// console.log('project mounted', this)
|
console.log('project mounted', this)
|
||||||
// mesh options
|
|
||||||
this.block3d = this.$refs.block3d.curObj
|
|
||||||
this.block3d.geometry = this.geometry
|
|
||||||
this.block3d.castShadow = true
|
|
||||||
this.block3d.receiveShadow = true
|
|
||||||
// record self references
|
// record self references
|
||||||
|
|
||||||
|
this.block3d = this.$refs.block3d.curObj
|
||||||
this.block3d.userData = {
|
this.block3d.userData = {
|
||||||
vnode: this
|
vnode: this
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user