@realsee/dnalogel 0.1.7-alpha.1 → 0.1.7-alpha.2
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/components/GLTFView/index.d.ts +10 -0
- package/components/GLTFView/index.js +11 -2
- package/libs/gltf-viewer/index.d.ts +5 -2
- package/libs/gltf-viewer/index.js +34 -10
- package/package.json +1 -1
- package/plugins/PanoMaskSelectorPlugin/fragmentShader.d.ts +1 -1
- package/plugins/PanoMaskSelectorPlugin/fragmentShader.js +1 -1
|
@@ -89,6 +89,16 @@ export declare type GLTFViewPropTypes = {
|
|
|
89
89
|
* .start()
|
|
90
90
|
*
|
|
91
91
|
* ```
|
|
92
|
+
*
|
|
93
|
+
* ### 光照配置
|
|
94
|
+
*
|
|
95
|
+
* ```ts
|
|
96
|
+
* pointLight?: THREE.PointLight | false
|
|
97
|
+
* directionalLight?: THREE.DirectionalLight | false
|
|
98
|
+
* ambientLight?: THREE.AmbientLight | false
|
|
99
|
+
* ```
|
|
100
|
+
* 自带三种默认光照配置,你可以提供自己的光照实例。如果设置 `pointLight: false` 则禁用该光照效果。
|
|
101
|
+
*
|
|
92
102
|
*/
|
|
93
103
|
export declare const GLTFView: React.FC<GLTFViewPropTypes>;
|
|
94
104
|
export default GLTFView;
|
|
@@ -119,6 +119,16 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
119
119
|
* .start()
|
|
120
120
|
*
|
|
121
121
|
* ```
|
|
122
|
+
*
|
|
123
|
+
* ### 光照配置
|
|
124
|
+
*
|
|
125
|
+
* ```ts
|
|
126
|
+
* pointLight?: THREE.PointLight | false
|
|
127
|
+
* directionalLight?: THREE.DirectionalLight | false
|
|
128
|
+
* ambientLight?: THREE.AmbientLight | false
|
|
129
|
+
* ```
|
|
130
|
+
* 自带三种默认光照配置,你可以提供自己的光照实例。如果设置 `pointLight: false` 则禁用该光照效果。
|
|
131
|
+
*
|
|
122
132
|
*/
|
|
123
133
|
var GLTFView = function GLTFView(props) {
|
|
124
134
|
var ref = React.useRef(null);
|
|
@@ -149,8 +159,7 @@ var GLTFView = function GLTFView(props) {
|
|
|
149
159
|
};
|
|
150
160
|
}();
|
|
151
161
|
|
|
152
|
-
callback();
|
|
153
|
-
console.log('refs', props.refs); // 实例
|
|
162
|
+
callback(); // 实例
|
|
154
163
|
|
|
155
164
|
if (props.refs) {
|
|
156
165
|
props.refs(gltfViewer);
|
|
@@ -11,8 +11,11 @@ export interface GLTFViewerConfig {
|
|
|
11
11
|
backgroundHDR?: string;
|
|
12
12
|
pixelRatio?: number;
|
|
13
13
|
initial?: Partial<GLTFViewerState>;
|
|
14
|
-
pointLight?: THREE.PointLight;
|
|
15
|
-
directionalLight?: THREE.DirectionalLight;
|
|
14
|
+
pointLight?: THREE.PointLight | false;
|
|
15
|
+
directionalLight?: THREE.DirectionalLight | false;
|
|
16
|
+
ambientLight?: THREE.AmbientLight | false;
|
|
17
|
+
minFov?: number;
|
|
18
|
+
maxFov?: number;
|
|
16
19
|
}
|
|
17
20
|
export interface GLTFViewerState {
|
|
18
21
|
fov: number;
|
|
@@ -41,6 +41,8 @@ require("core-js/modules/es.number.is-integer.js");
|
|
|
41
41
|
|
|
42
42
|
require("core-js/modules/es.number.constructor.js");
|
|
43
43
|
|
|
44
|
+
require("core-js/modules/es.array.concat.js");
|
|
45
|
+
|
|
44
46
|
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
45
47
|
|
|
46
48
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
@@ -104,7 +106,8 @@ var Controller = /*#__PURE__*/function () {
|
|
|
104
106
|
(0, _defineProperty2["default"])(this, "longitude", 0);
|
|
105
107
|
(0, _defineProperty2["default"])(this, "latitude", -0.3);
|
|
106
108
|
(0, _defineProperty2["default"])(this, "needsRender", false);
|
|
107
|
-
// 异步事件回调
|
|
109
|
+
this.config = config; // 异步事件回调
|
|
110
|
+
|
|
108
111
|
this.callbacks = callbacks; // 默认状态参数
|
|
109
112
|
|
|
110
113
|
var initial = config.initial || {};
|
|
@@ -149,11 +152,22 @@ var Controller = /*#__PURE__*/function () {
|
|
|
149
152
|
|
|
150
153
|
this.camera = new THREE.PerspectiveCamera(this.fov, 1, 0.1, 10000); // 光照
|
|
151
154
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
155
|
+
if (config.pointLight !== false) {
|
|
156
|
+
this.pointLight = config.pointLight || new THREE.PointLight(0xfffffff, 1, 100000);
|
|
157
|
+
this.scene.add(this.pointLight);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (config.directionalLight !== false) {
|
|
161
|
+
this.directionLight = config.directionalLight || new THREE.DirectionalLight(0xfffffff, 0.1);
|
|
162
|
+
this.directionLight.position.setY(-1);
|
|
163
|
+
this.scene.add(this.directionLight);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (config.ambientLight !== false) {
|
|
167
|
+
this.ambientLight = config.ambientLight || new THREE.AmbientLight(0xfffffff);
|
|
168
|
+
this.scene.add(this.ambientLight);
|
|
169
|
+
} // 背景 HDR
|
|
170
|
+
|
|
157
171
|
|
|
158
172
|
if (config.backgroundHDR) {
|
|
159
173
|
var pmremGenerator = new THREE.PMREMGenerator(this.renderer);
|
|
@@ -205,6 +219,16 @@ var Controller = /*#__PURE__*/function () {
|
|
|
205
219
|
}
|
|
206
220
|
|
|
207
221
|
(0, _createClass2["default"])(Controller, [{
|
|
222
|
+
key: "minFov",
|
|
223
|
+
get: function get() {
|
|
224
|
+
return this.config.minFov || 20;
|
|
225
|
+
}
|
|
226
|
+
}, {
|
|
227
|
+
key: "maxFov",
|
|
228
|
+
get: function get() {
|
|
229
|
+
return this.config.maxFov || 120;
|
|
230
|
+
}
|
|
231
|
+
}, {
|
|
208
232
|
key: "pause",
|
|
209
233
|
value: function pause() {// nothing todo
|
|
210
234
|
}
|
|
@@ -333,10 +357,10 @@ var Controller = /*#__PURE__*/function () {
|
|
|
333
357
|
latitude: -Math.PI / 6
|
|
334
358
|
});
|
|
335
359
|
lightDirection.setLength(distance * 3);
|
|
336
|
-
this.pointLight.position.copy(center.clone().add(lightDirection));
|
|
360
|
+
if (this.pointLight) this.pointLight.position.copy(center.clone().add(lightDirection));
|
|
337
361
|
|
|
338
362
|
if (fov !== this.fov) {
|
|
339
|
-
fov = Math.max(25, Math.min(
|
|
363
|
+
fov = Math.max(25, Math.min(this.maxFov, fov));
|
|
340
364
|
this.camera.fov = fov;
|
|
341
365
|
this.camera.updateProjectionMatrix();
|
|
342
366
|
}
|
|
@@ -578,8 +602,8 @@ var GLTFViewer = /*#__PURE__*/function (_Subscribe) {
|
|
|
578
602
|
throw new TypeError('The fov is not an number');
|
|
579
603
|
}
|
|
580
604
|
|
|
581
|
-
if (value >
|
|
582
|
-
throw new RangeError(
|
|
605
|
+
if (value > controller.maxFov || value < controller.minFov) {
|
|
606
|
+
throw new RangeError("The fov seems invalid~ fov: [".concat(controller.minFov, ", ").concat(controller.maxFov, "]"));
|
|
583
607
|
}
|
|
584
608
|
}
|
|
585
609
|
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const fragmentShader = "\nconst float PI = 3.1415926535897932384626433832795;\nuniform int enable;\nuniform sampler2D map;\nvarying vec2 vUv;\n\nuniform vec3 selectedColor;\nuniform vec3 maskColor;\nuniform float opacity;\nuniform float thickness;\n\n\n// \u5224\u65AD\u4E24\u4E2A\u989C\u8272\u662F\u5426\u76F8\u4F3C\nbool compare(vec3 c1, vec3 c2, float threshold) {\n // \u8272\u503C\u8BEF\u5DEE 0.05\n float diff = threshold;\n\n float r = abs(c1.x - c2.x);\n float g = abs(c1.y - c2.y);\n float b = abs(c1.z - c2.z);\n\n return r < diff && g < diff && b < diff;\n}\n\nvoid main(void) {\n vec3 color = texture2D(map, vUv).xyz;\n float alpha = texture2D(map, vUv).a;\n\n gl_FragColor = vec4(color,
|
|
1
|
+
export declare const fragmentShader = "\nconst float PI = 3.1415926535897932384626433832795;\nuniform int enable;\nuniform sampler2D map;\nvarying vec2 vUv;\n\nuniform vec3 selectedColor;\nuniform vec3 maskColor;\nuniform float opacity;\nuniform float thickness;\n\n\n// \u5224\u65AD\u4E24\u4E2A\u989C\u8272\u662F\u5426\u76F8\u4F3C\nbool compare(vec3 c1, vec3 c2, float threshold) {\n // \u8272\u503C\u8BEF\u5DEE 0.05\n float diff = threshold;\n\n float r = abs(c1.x - c2.x);\n float g = abs(c1.y - c2.y);\n float b = abs(c1.z - c2.z);\n\n return r < diff && g < diff && b < diff;\n}\n\nvoid main(void) {\n vec3 color = texture2D(map, vUv).xyz;\n float alpha = texture2D(map, vUv).a;\n\n gl_FragColor = vec4(color, opacity);\n\n // \u5F00\u5173\n if (enable != 1) {\n gl_FragColor = vec4(color, opacity);\n return;\n }\n\n // \u9ED8\u8BA4\u503C\uFF1A\u672A\u63D0\u4F9B \u9009\u4E2D\u8272\u503C\n if (selectedColor.x == 0.0 && selectedColor.y == 0.0 && selectedColor.z == 0.0) {\n gl_FragColor = vec4(color, opacity);\n return;\n }\n\n bool similar = compare(color, selectedColor, 0.025);\n\n // \u4E0D\u76F8\u4F3C\n if (similar == false) {\n gl_FragColor = vec4(color, opacity);\n return;\n }\n\n // \u5BF9\u6BD4\u534A\u5F84\u5E45\u5EA6\n float offset1 = thickness;\n float offset2 = offset1 * sin(PI/4.0);\n\n vec3 top = texture2D(map, vec2(vUv.x, vUv.y + offset1)).xyz;\n vec3 right = texture2D(map, vec2(vUv.x + offset1, vUv.y)).xyz;\n vec3 bottom = texture2D(map, vec2(vUv.x, vUv.y - offset1)).xyz;\n vec3 left = texture2D(map, vec2(vUv.x - offset1, vUv.y)).xyz;\n \n vec3 topRight = texture2D(map, vec2(vUv.x + offset2, vUv.y + offset2)).xyz;\n vec3 rightBottom = texture2D(map, vec2(vUv.x + offset2, vUv.y - offset2)).xyz;\n vec3 bottomLeft = texture2D(map, vec2(vUv.x - offset2, vUv.y - offset2)).xyz;\n vec3 leftTop = texture2D(map, vec2(vUv.x - offset2, vUv.y + offset2)).xyz;\n\n float threshold = 0.0025;\n bool a1 = compare(color, top, threshold);\n bool b1 = compare(color, right, threshold);\n bool c1 = compare(color, bottom, threshold);\n bool d1 = compare(color, left, threshold);\n\n\n bool a2 = compare(color, topRight, threshold);\n bool b2 = compare(color, rightBottom, threshold);\n bool c2 = compare(color, bottomLeft, threshold);\n bool d2 = compare(color, leftTop, threshold);\n\n if (a1 == true && b1 == true && c1 == true && d1 == true && a2 == true && b2 == true && c2 == true && d2 == true) {\n gl_FragColor = vec4(color, opacity);\n return;\n }\n\n gl_FragColor = vec4(maskColor.x, maskColor.y, maskColor.z, 1.0);\n // gl_FragColor = vec4(154.0 / 255.0, 205.0 / 255.0, 50.0 / 255.0, 1.0) ;\n // gl_FragColor = vec4(139.0 / 255.0, 0.0 / 255.0, 0.0 / 255.0, 1.0) ;\n // gl_FragColor = vec4(255.0 / 255.0, 235.0 / 255.0, 59.0 / 255.0, 1.0) ;\n\n}\n";
|
|
@@ -6,5 +6,5 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.fragmentShader = void 0;
|
|
9
|
-
var fragmentShader = "\nconst float PI = 3.1415926535897932384626433832795;\nuniform int enable;\nuniform sampler2D map;\nvarying vec2 vUv;\n\nuniform vec3 selectedColor;\nuniform vec3 maskColor;\nuniform float opacity;\nuniform float thickness;\n\n\n// \u5224\u65AD\u4E24\u4E2A\u989C\u8272\u662F\u5426\u76F8\u4F3C\nbool compare(vec3 c1, vec3 c2, float threshold) {\n // \u8272\u503C\u8BEF\u5DEE 0.05\n float diff = threshold;\n\n float r = abs(c1.x - c2.x);\n float g = abs(c1.y - c2.y);\n float b = abs(c1.z - c2.z);\n\n return r < diff && g < diff && b < diff;\n}\n\nvoid main(void) {\n vec3 color = texture2D(map, vUv).xyz;\n float alpha = texture2D(map, vUv).a;\n\n gl_FragColor = vec4(color,
|
|
9
|
+
var fragmentShader = "\nconst float PI = 3.1415926535897932384626433832795;\nuniform int enable;\nuniform sampler2D map;\nvarying vec2 vUv;\n\nuniform vec3 selectedColor;\nuniform vec3 maskColor;\nuniform float opacity;\nuniform float thickness;\n\n\n// \u5224\u65AD\u4E24\u4E2A\u989C\u8272\u662F\u5426\u76F8\u4F3C\nbool compare(vec3 c1, vec3 c2, float threshold) {\n // \u8272\u503C\u8BEF\u5DEE 0.05\n float diff = threshold;\n\n float r = abs(c1.x - c2.x);\n float g = abs(c1.y - c2.y);\n float b = abs(c1.z - c2.z);\n\n return r < diff && g < diff && b < diff;\n}\n\nvoid main(void) {\n vec3 color = texture2D(map, vUv).xyz;\n float alpha = texture2D(map, vUv).a;\n\n gl_FragColor = vec4(color, opacity);\n\n // \u5F00\u5173\n if (enable != 1) {\n gl_FragColor = vec4(color, opacity);\n return;\n }\n\n // \u9ED8\u8BA4\u503C\uFF1A\u672A\u63D0\u4F9B \u9009\u4E2D\u8272\u503C\n if (selectedColor.x == 0.0 && selectedColor.y == 0.0 && selectedColor.z == 0.0) {\n gl_FragColor = vec4(color, opacity);\n return;\n }\n\n bool similar = compare(color, selectedColor, 0.025);\n\n // \u4E0D\u76F8\u4F3C\n if (similar == false) {\n gl_FragColor = vec4(color, opacity);\n return;\n }\n\n // \u5BF9\u6BD4\u534A\u5F84\u5E45\u5EA6\n float offset1 = thickness;\n float offset2 = offset1 * sin(PI/4.0);\n\n vec3 top = texture2D(map, vec2(vUv.x, vUv.y + offset1)).xyz;\n vec3 right = texture2D(map, vec2(vUv.x + offset1, vUv.y)).xyz;\n vec3 bottom = texture2D(map, vec2(vUv.x, vUv.y - offset1)).xyz;\n vec3 left = texture2D(map, vec2(vUv.x - offset1, vUv.y)).xyz;\n \n vec3 topRight = texture2D(map, vec2(vUv.x + offset2, vUv.y + offset2)).xyz;\n vec3 rightBottom = texture2D(map, vec2(vUv.x + offset2, vUv.y - offset2)).xyz;\n vec3 bottomLeft = texture2D(map, vec2(vUv.x - offset2, vUv.y - offset2)).xyz;\n vec3 leftTop = texture2D(map, vec2(vUv.x - offset2, vUv.y + offset2)).xyz;\n\n float threshold = 0.0025;\n bool a1 = compare(color, top, threshold);\n bool b1 = compare(color, right, threshold);\n bool c1 = compare(color, bottom, threshold);\n bool d1 = compare(color, left, threshold);\n\n\n bool a2 = compare(color, topRight, threshold);\n bool b2 = compare(color, rightBottom, threshold);\n bool c2 = compare(color, bottomLeft, threshold);\n bool d2 = compare(color, leftTop, threshold);\n\n if (a1 == true && b1 == true && c1 == true && d1 == true && a2 == true && b2 == true && c2 == true && d2 == true) {\n gl_FragColor = vec4(color, opacity);\n return;\n }\n\n gl_FragColor = vec4(maskColor.x, maskColor.y, maskColor.z, 1.0);\n // gl_FragColor = vec4(154.0 / 255.0, 205.0 / 255.0, 50.0 / 255.0, 1.0) ;\n // gl_FragColor = vec4(139.0 / 255.0, 0.0 / 255.0, 0.0 / 255.0, 1.0) ;\n // gl_FragColor = vec4(255.0 / 255.0, 235.0 / 255.0, 59.0 / 255.0, 1.0) ;\n\n}\n";
|
|
10
10
|
exports.fragmentShader = fragmentShader;
|