bring back ground occluder
This commit is contained in:
@@ -239,6 +239,7 @@ export const ZoneRenderer = ({ node }: { node: ZoneNode }) => {
|
|||||||
rotation={[-Math.PI / 2, 0, 0]}
|
rotation={[-Math.PI / 2, 0, 0]}
|
||||||
material={floorMaterial}
|
material={floorMaterial}
|
||||||
name="floor"
|
name="floor"
|
||||||
|
layers={2}
|
||||||
>
|
>
|
||||||
<shapeGeometry args={[floorShape]} />
|
<shapeGeometry args={[floorShape]} />
|
||||||
</mesh>
|
</mesh>
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { useScene } from '@pascal-app/core'
|
import { useScene } from '@pascal-app/core'
|
||||||
|
import polygonClipping from 'polygon-clipping'
|
||||||
import { useMemo } from 'react'
|
import { useMemo } from 'react'
|
||||||
import * as THREE from 'three'
|
import * as THREE from 'three'
|
||||||
import useViewer from '../../store/use-viewer'
|
import useViewer from '../../store/use-viewer'
|
||||||
import polygonClipping from 'polygon-clipping'
|
|
||||||
|
|
||||||
export const GroundOccluder = () => {
|
export const GroundOccluder = () => {
|
||||||
const theme = useViewer((state) => state.theme)
|
const theme = useViewer((state) => state.theme)
|
||||||
@@ -24,15 +24,15 @@ export const GroundOccluder = () => {
|
|||||||
const polygons: [number, number][][] = []
|
const polygons: [number, number][][] = []
|
||||||
|
|
||||||
Object.values(nodes).forEach((node) => {
|
Object.values(nodes).forEach((node) => {
|
||||||
if ((node.type === 'slab' || node.type === 'zone') && node.polygon && node.polygon.length >= 3) {
|
if (node.type === 'slab' && node.polygon && node.polygon.length >= 3) {
|
||||||
polygons.push(node.polygon as [number, number][])
|
polygons.push(node.polygon as [number, number][])
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
if (polygons.length > 0) {
|
if (polygons.length > 0) {
|
||||||
// Format for polygon-clipping: [[[x, y], [x, y], ...]]
|
// Format for polygon-clipping: [[[x, y], [x, y], ...]]
|
||||||
const multiPolygons = polygons.map(pts => {
|
const multiPolygons = polygons.map((pts) => {
|
||||||
const ring = pts.map(p => [p[0], -p[1]] as [number, number]) // Negate Y (which was Z)
|
const ring = pts.map((p) => [p[0], -p[1]] as [number, number]) // Negate Y (which was Z)
|
||||||
return [ring]
|
return [ring]
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user