Skip to content

Commit

Permalink
threejs bump
Browse files Browse the repository at this point in the history
  • Loading branch information
artur-trzesiok committed Jan 28, 2022
1 parent 1fa4c99 commit f2c6352
Show file tree
Hide file tree
Showing 13 changed files with 23 additions and 31 deletions.
2 changes: 1 addition & 1 deletion js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"screenfull": "^5.1.0",
"stats.js": "^0.17.0",
"style-loader": "^2.0.0",
"three": "^0.128.0",
"three": "^0.137.4",
"three-mesh-bvh": "^0.3.7"
}
}
3 changes: 1 addition & 2 deletions js/src/providers/threejs/helpers/THREE.MeshLine.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,6 @@ module.exports = function (THREE) {
return v;
}

THREE.Material.call(this);

parameters = parameters || {};

this.lineWidth = check(parameters.lineWidth, 1);
Expand Down Expand Up @@ -393,6 +391,7 @@ module.exports = function (THREE) {

MeshLineMaterial.prototype = Object.create(THREE.Material.prototype);
MeshLineMaterial.prototype.constructor = MeshLineMaterial;
MeshLineMaterial.prototype.isMeshLineMaterial = true;

MeshLineMaterial.prototype.copy = function (source) {
THREE.Material.prototype.copy.call(this, source);
Expand Down
4 changes: 2 additions & 2 deletions js/src/providers/threejs/objects/MarchingCubes.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const THREE = require('three');
const { BufferGeometryUtils } = require('three/examples/jsm/utils/BufferGeometryUtils');
const BufferGeometryUtils = require('three/examples/jsm/utils/BufferGeometryUtils');
const intersectHelper = require('../helpers/Intersection');
const marchingCubesPolygonise = require('../../../core/lib/helpers/marchingCubesPolygonise');
const yieldingLoop = require('../../../core/lib/helpers/yieldingLoop');
Expand Down Expand Up @@ -38,7 +38,7 @@ module.exports = {
emissive: 0,
shininess: 50,
specular: 0x111111,
side: THREE.DoubleSide,
side: config.wireframe ? THREE.FrontSide : THREE.DoubleSide,
flatShading: config.flat_shading,
wireframe: config.wireframe,
opacity: config.opacity,
Expand Down
2 changes: 1 addition & 1 deletion js/src/providers/threejs/objects/STL.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const THREE = require('three');
const { BufferGeometryUtils } = require('three/examples/jsm/utils/BufferGeometryUtils');
const BufferGeometryUtils = require('three/examples/jsm/utils/BufferGeometryUtils');
const { areAllChangesResolve } = require('../helpers/Fn');
const { commonUpdate } = require('../helpers/Fn');

Expand Down
2 changes: 1 addition & 1 deletion js/src/providers/threejs/objects/VectorField.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const THREE = require('three');
const { BufferGeometryUtils } = require('three/examples/jsm/utils/BufferGeometryUtils');
const BufferGeometryUtils = require('three/examples/jsm/utils/BufferGeometryUtils');
const buffer = require('../../../core/lib/helpers/buffer');
const { areAllChangesResolve } = require('../helpers/Fn');
const { commonUpdate } = require('../helpers/Fn');
Expand Down
2 changes: 1 addition & 1 deletion js/src/providers/threejs/objects/Vectors.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const THREE = require('three');
const { BufferGeometryUtils } = require('three/examples/jsm/utils/BufferGeometryUtils');
const BufferGeometryUtils = require('three/examples/jsm/utils/BufferGeometryUtils');
const buffer = require('../../../core/lib/helpers/buffer');
const MeshLine = require('../helpers/THREE.MeshLine')(THREE);
const { getTwoColorsArray } = require('../helpers/Fn');
Expand Down
1 change: 0 additions & 1 deletion js/src/providers/threejs/objects/Volume.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ module.exports = {
THREE.UniformsLib.lights,
),
defines: {
USE_SPECULAR: 1,
USE_SHADOW: (config.shadow !== 'off' ? 1 : 0),
RAY_SAMPLES_COUNT: config.focal_length !== 0.0 ? config.ray_samples_count : 0,
},
Expand Down
6 changes: 3 additions & 3 deletions js/src/providers/threejs/objects/shaders/MIP.fragment.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ void main() {

// LIGHT
#if NUM_DIR_LIGHTS > 0
vec4 addedLights = vec4(ambientLightColor, 1.0);
vec4 addedLights = vec4(ambientLightColor / PI, 1.0);
vec3 normal = worldGetNormal(px, maxTextcoord);

vec3 lightDirection;
Expand All @@ -155,10 +155,10 @@ void main() {
for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
lightDirection = -directionalLights[ i ].direction;
lightingIntensity = clamp(dot(-lightDirection, normal), 0.0, 1.0);
addedLights.rgb += directionalLights[ i ].color * (0.05 + 0.95 * lightingIntensity);
addedLights.rgb += directionalLights[ i ].color / PI * (0.05 + 0.95 * lightingIntensity);

#if (USE_SPECULAR == 1)
pxColor.rgb += directionalLights[ i ].color * pow(lightingIntensity, 50.0) * pxColor.a;
pxColor.rgb += directionalLights[ i ].color / PI * pow(lightingIntensity, 50.0) * pxColor.a;
#endif
}
#pragma unroll_loop_end
Expand Down
22 changes: 8 additions & 14 deletions js/src/providers/threejs/objects/shaders/Points.3d.fragment.glsl
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
#include <common>
#include <clipping_planes_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <lights_pars_begin>

uniform float size;
uniform float specular;
uniform float opacity;
uniform mat4 projectionMatrix;
uniform vec3 ambientLightColor;

varying vec4 vColor;
varying vec4 mvPosition;

struct DirectionalLight {
vec3 direction;
vec3 color;
};

uniform DirectionalLight directionalLights[NUM_DIR_LIGHTS];

#include <clipping_planes_pars_fragment>
#include <logdepthbuf_pars_fragment>

void main (void)
{
#include <clipping_planes_fragment>
Expand Down Expand Up @@ -45,18 +39,18 @@ void main (void)

vec3 normal = vec3(impostorSpaceCoordinate, normalizedDepth);

vec4 addedLights = vec4(ambientLightColor, 1.0);
vec4 addedLights = vec4(ambientLightColor / PI, 1.0);
vec4 finalSphereColor = vColor;

finalSphereColor.a *= opacity;

for (int l = 0; l <NUM_DIR_LIGHTS; l++) {
vec3 lightDirection = -directionalLights[l].direction;
float lightingIntensity = clamp(dot(-lightDirection, normal), 0.0, 1.0);
addedLights.rgb += directionalLights[l].color * (0.05 + 0.95 * lightingIntensity);
addedLights.rgb += directionalLights[l].color / PI * (0.05 + 0.95 * lightingIntensity);

#if (USE_SPECULAR == 1)
finalSphereColor.rgb += directionalLights[l].color * pow(lightingIntensity, 80.0);
finalSphereColor.rgb += directionalLights[l].color / PI * pow(lightingIntensity, 80.0);
#endif
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ uniform float opacity;
#include <clipping_planes_pars_fragment>

varying float perPointOpacity;
varying vec3 vNormal;

void main() {

Expand Down
7 changes: 3 additions & 4 deletions js/src/providers/threejs/objects/shaders/Volume.fragment.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -216,30 +216,29 @@ void main() {

// LIGHT
#if NUM_DIR_LIGHTS > 0
vec4 addedLights = vec4(ambientLightColor, 1.0);
vec4 addedLights = vec4(ambientLightColor / PI, 1.0);
vec3 specularColor = vec3(0.0);

vec3 normal = worldGetNormal(px, textcoord);

vec3 lightDirection;
float lightingIntensity;

// vec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );
vec3 lightReflect;
float specularFactor;

#pragma unroll_loop_start
for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
lightDirection = directionalLights[ i ].direction;
lightingIntensity = clamp(dot(lightDirection, normal), 0.0, 1.0);
addedLights.rgb += directionalLights[ i ].color * (0.2 + 0.8 * lightingIntensity) * (1.0 - shadow);
addedLights.rgb += directionalLights[ i ].color / PI * (0.2 + 0.8 * lightingIntensity) * (1.0 - shadow);

lightReflect = normalize(reflect(lightDirection, normal));
specularFactor = dot(direction, lightReflect);

if (specularFactor > 0.0)
specularColor += 0.002 * scaled_px * (1.0 / step) *
directionalLights[ i ].color * pow(specularFactor, 250.0) *
directionalLights[ i ].color / PI * pow(specularFactor, 250.0) *
pxColor.a * (1.0 - shadow);
}
#pragma unroll_loop_end
Expand Down
Binary file modified k3d/test/references/voxels_outline_opacity.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"screenfull": "^5.1.0",
"stats.js": "^0.17.0",
"style-loader": "^2.0.0",
"three": "^0.128.0",
"three": "^0.137.4",
"three-mesh-bvh": "^0.3.7"
},
"devDependencies": {
Expand Down

0 comments on commit f2c6352

Please sign in to comment.