Browse Source

地板不透明

master
修宁 6 months ago
parent
commit
9ea6474ce4
  1. 14
      src/core/engine/SceneHelp.ts

14
src/core/engine/SceneHelp.ts

@ -4,7 +4,6 @@ import { LineGeometry } from 'three/examples/jsm/lines/LineGeometry'
import { LineMaterial } from 'three/examples/jsm/lines/LineMaterial' import { LineMaterial } from 'three/examples/jsm/lines/LineMaterial'
import { Line2 } from 'three/examples/jsm/lines/Line2' import { Line2 } from 'three/examples/jsm/lines/Line2'
import type { Object3DLike } from '@/types/ModelTypes.ts' import type { Object3DLike } from '@/types/ModelTypes.ts'
import { LineWrap } from '@/core/manager/LineSegmentManager.ts'
/** /**
* *
@ -33,12 +32,14 @@ export default class SceneHelp {
this.scene = new THREE.Scene() this.scene = new THREE.Scene()
this.scene.background = new THREE.Color(gridOption.backgroundColor) this.scene.background = new THREE.Color(gridOption.backgroundColor)
// 中心十字坐标
if (gridOption.axesEnabled) { if (gridOption.axesEnabled) {
this.axesHelper = createAxes(gridOption.axesSize, gridOption.axesColor, gridOption.axesWidth) this.axesHelper = createAxes(gridOption.axesSize, gridOption.axesColor, gridOption.axesWidth)
this.axesHelper.position.setY(0) // 确保网格在地面上方 this.axesHelper.position.setY(0) // 确保网格在地面上方
this.scene.add(this.axesHelper) this.scene.add(this.axesHelper)
} }
// 1 米级地板
const gridHelper = new THREE.GridHelper(gridOption.gridSize, gridOption.gridDivisions) const gridHelper = new THREE.GridHelper(gridOption.gridSize, gridOption.gridDivisions)
gridHelper.material.color.setHex(gridOption.gridColor) gridHelper.material.color.setHex(gridOption.gridColor)
gridHelper.material.opacity = gridOption.gridOpacity gridHelper.material.opacity = gridOption.gridOpacity
@ -52,6 +53,7 @@ export default class SceneHelp {
this.gridHelper = gridHelper this.gridHelper = gridHelper
this.scene.add(this.gridHelper) this.scene.add(this.gridHelper)
// 10 米级地板
const gridHelper2 = new THREE.GridHelper(1000, 100) const gridHelper2 = new THREE.GridHelper(1000, 100)
gridHelper2.material.color.setHex(gridOption.gridColor) gridHelper2.material.color.setHex(gridOption.gridColor)
gridHelper2.material.transparent = false gridHelper2.material.transparent = false
@ -78,6 +80,16 @@ export default class SceneHelp {
const hemisphereLight = new THREE.HemisphereLight(0xffffff, 0x444444, 1) const hemisphereLight = new THREE.HemisphereLight(0xffffff, 0x444444, 1)
this.scene.add(hemisphereLight) this.scene.add(hemisphereLight)
// 完全不透明的地板
const geometry = new THREE.PlaneGeometry(gridOption.gridSize, gridOption.gridSize)
const material = new THREE.MeshBasicMaterial({
color: '#ffffff',
side: THREE.BackSide
})
const ground = new THREE.Mesh(geometry, material)
ground.rotation.x = -Math.PI / 2
this.scene.add(ground)
// const directionalLight = new THREE.DirectionalLight(0xffffff, 1.5) // const directionalLight = new THREE.DirectionalLight(0xffffff, 1.5)
// directionalLight.position.set(5, 5, 5).multiplyScalar(3) // directionalLight.position.set(5, 5, 5).multiplyScalar(3)
// directionalLight.castShadow = true // directionalLight.castShadow = true

Loading…
Cancel
Save