three-base 2.0.109 → 2.0.110
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ThreeMouse.js +8 -0
- package/package.json +3 -2
- package/shaders.js +2 -11
package/ThreeMouse.js
CHANGED
|
@@ -7,6 +7,11 @@
|
|
|
7
7
|
import * as THREE from "three";
|
|
8
8
|
import { Raycaster } from "three";
|
|
9
9
|
import { debounce } from "lodash";
|
|
10
|
+
import { computeBoundsTree, disposeBoundsTree, acceleratedRaycast } from 'three-mesh-bvh';
|
|
11
|
+
// Add the extension functions
|
|
12
|
+
THREE.BufferGeometry.prototype.computeBoundsTree = computeBoundsTree;
|
|
13
|
+
THREE.BufferGeometry.prototype.disposeBoundsTree = disposeBoundsTree;
|
|
14
|
+
THREE.Mesh.prototype.raycast = acceleratedRaycast;
|
|
10
15
|
/**
|
|
11
16
|
* three.js 专用的鼠标拾取模型对象
|
|
12
17
|
*/
|
|
@@ -98,6 +103,9 @@ export default class ThreeMouse {
|
|
|
98
103
|
this._scene.traverseVisible(mesh => {
|
|
99
104
|
// 判断对象是否有指定的事件
|
|
100
105
|
if (this.hasCursor(mesh) || this.hasEvent(mesh, ["leftclick", "rightclick", "click", "dbclick", "mouseenter", "mouseleave", "mousemove", "mousedown", "mouseup"])) {
|
|
106
|
+
if (mesh.isMesh && !mesh.geometry.boundsTree) {
|
|
107
|
+
mesh.geometry.computeBoundsTree();
|
|
108
|
+
}
|
|
101
109
|
meshs.push(mesh);
|
|
102
110
|
}
|
|
103
111
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "three-base",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.110",
|
|
4
4
|
"description": "three 3d three-base",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
"dexie": "^3",
|
|
45
45
|
"vite": "*",
|
|
46
46
|
"jszip": "^3.10.1",
|
|
47
|
-
"html2canvas": "^1.4.1"
|
|
47
|
+
"html2canvas": "^1.4.1",
|
|
48
|
+
"three-mesh-bvh": "^0.8.3"
|
|
48
49
|
}
|
|
49
50
|
}
|
package/shaders.js
CHANGED
|
@@ -89,7 +89,7 @@ export const intersectionShader = new ShaderMaterial({
|
|
|
89
89
|
export const copyShader = new ShaderMaterial({
|
|
90
90
|
uniforms: {
|
|
91
91
|
map: { value: null },
|
|
92
|
-
opacity: { value: 1.0 } // 透明度
|
|
92
|
+
opacity: { value: 1.0 }, // 透明度
|
|
93
93
|
},
|
|
94
94
|
vertexShader: `
|
|
95
95
|
${ShaderChunk.common}
|
|
@@ -105,7 +105,6 @@ export const copyShader = new ShaderMaterial({
|
|
|
105
105
|
${ShaderChunk.logdepthbuf_pars_fragment}
|
|
106
106
|
uniform sampler2D map;
|
|
107
107
|
uniform float opacity;
|
|
108
|
-
uniform bool linear_to_srgb;
|
|
109
108
|
varying vec2 vUv;
|
|
110
109
|
void main() {
|
|
111
110
|
vec4 diffuseColor = texture(map, vUv);
|
|
@@ -137,17 +136,9 @@ export const baseTextureToRenderShader = new ShaderMaterial({
|
|
|
137
136
|
${ShaderChunk.logdepthbuf_pars_fragment}
|
|
138
137
|
uniform sampler2D map;
|
|
139
138
|
uniform float opacity;
|
|
140
|
-
uniform bool linear_to_srgb;
|
|
141
139
|
varying vec2 vUv;
|
|
142
|
-
float linearToSrgb(float v) {
|
|
143
|
-
return pow(v, 1.0 / 2.2);
|
|
144
|
-
}
|
|
145
140
|
void main() {
|
|
146
|
-
|
|
147
|
-
diffuseColor.r = linearToSrgb(diffuseColor.r);
|
|
148
|
-
diffuseColor.g = linearToSrgb(diffuseColor.g);
|
|
149
|
-
diffuseColor.b = linearToSrgb(diffuseColor.b);
|
|
150
|
-
gl_FragColor = diffuseColor * opacity;
|
|
141
|
+
gl_FragColor = sRGBTransferOETF(texture(map, vUv));
|
|
151
142
|
${ShaderChunk.logdepthbuf_fragment}
|
|
152
143
|
}
|
|
153
144
|
`,
|