UNPKG

three-stdlib

Version:

stand-alone library of threejs examples

1 lines 3.6 kB
{"version":3,"file":"BoxLineGeometry.cjs","sources":["../../src/geometries/BoxLineGeometry.js"],"sourcesContent":["import { BufferGeometry, Float32BufferAttribute } from 'three'\n\nclass BoxLineGeometry extends BufferGeometry {\n constructor(width, height, depth, widthSegments, heightSegments, depthSegments) {\n super()\n\n width = width || 1\n height = height || 1\n depth = depth || 1\n\n widthSegments = Math.floor(widthSegments) || 1\n heightSegments = Math.floor(heightSegments) || 1\n depthSegments = Math.floor(depthSegments) || 1\n\n const widthHalf = width / 2\n const heightHalf = height / 2\n const depthHalf = depth / 2\n\n const segmentWidth = width / widthSegments\n const segmentHeight = height / heightSegments\n const segmentDepth = depth / depthSegments\n\n const vertices = []\n\n let x = -widthHalf,\n y = -heightHalf,\n z = -depthHalf\n\n for (let i = 0; i <= widthSegments; i++) {\n vertices.push(x, -heightHalf, -depthHalf, x, heightHalf, -depthHalf)\n vertices.push(x, heightHalf, -depthHalf, x, heightHalf, depthHalf)\n vertices.push(x, heightHalf, depthHalf, x, -heightHalf, depthHalf)\n vertices.push(x, -heightHalf, depthHalf, x, -heightHalf, -depthHalf)\n\n x += segmentWidth\n }\n\n for (let i = 0; i <= heightSegments; i++) {\n vertices.push(-widthHalf, y, -depthHalf, widthHalf, y, -depthHalf)\n vertices.push(widthHalf, y, -depthHalf, widthHalf, y, depthHalf)\n vertices.push(widthHalf, y, depthHalf, -widthHalf, y, depthHalf)\n vertices.push(-widthHalf, y, depthHalf, -widthHalf, y, -depthHalf)\n\n y += segmentHeight\n }\n\n for (let i = 0; i <= depthSegments; i++) {\n vertices.push(-widthHalf, -heightHalf, z, -widthHalf, heightHalf, z)\n vertices.push(-widthHalf, heightHalf, z, widthHalf, heightHalf, z)\n vertices.push(widthHalf, heightHalf, z, widthHalf, -heightHalf, z)\n vertices.push(widthHalf, -heightHalf, z, -widthHalf, -heightHalf, z)\n\n z += segmentDepth\n }\n\n this.setAttribute('position', new Float32Buffer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