|
@@ -1,5 +1,6 @@
|
|
import {
|
|
import {
|
|
BufferGeometry,
|
|
BufferGeometry,
|
|
|
|
+ Color,
|
|
Data3DTexture,
|
|
Data3DTexture,
|
|
FileLoader,
|
|
FileLoader,
|
|
Float32BufferAttribute,
|
|
Float32BufferAttribute,
|
|
@@ -8,7 +9,8 @@ import {
|
|
Mesh,
|
|
Mesh,
|
|
MeshStandardMaterial,
|
|
MeshStandardMaterial,
|
|
NearestFilter,
|
|
NearestFilter,
|
|
- RedFormat
|
|
|
|
|
|
+ RedFormat,
|
|
|
|
+ SRGBColorSpace
|
|
} from 'three';
|
|
} from 'three';
|
|
|
|
|
|
class VOXLoader extends Loader {
|
|
class VOXLoader extends Loader {
|
|
@@ -184,6 +186,8 @@ class VOXMesh extends Mesh {
|
|
const nz = [ 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0 ];
|
|
const nz = [ 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0 ];
|
|
const pz = [ 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1 ];
|
|
const pz = [ 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1 ];
|
|
|
|
|
|
|
|
+ const _color = new Color();
|
|
|
|
+
|
|
function add( tile, x, y, z, r, g, b ) {
|
|
function add( tile, x, y, z, r, g, b ) {
|
|
|
|
|
|
x -= size.x / 2;
|
|
x -= size.x / 2;
|
|
@@ -192,8 +196,10 @@ class VOXMesh extends Mesh {
|
|
|
|
|
|
for ( let i = 0; i < 18; i += 3 ) {
|
|
for ( let i = 0; i < 18; i += 3 ) {
|
|
|
|
|
|
|
|
+ _color.setRGB( r, g, b, SRGBColorSpace );
|
|
|
|
+
|
|
vertices.push( tile[ i + 0 ] + x, tile[ i + 1 ] + y, tile[ i + 2 ] + z );
|
|
vertices.push( tile[ i + 0 ] + x, tile[ i + 1 ] + y, tile[ i + 2 ] + z );
|
|
- colors.push( r, g, b );
|
|
|
|
|
|
+ colors.push( _color.r, _color.g, _color.b );
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|