@anov/3d-ability 0.0.4-alpha1
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/README.md +1 -0
- package/dist/city/flyinglead.d.ts +0 -0
- package/dist/city/flyinglead.js +0 -0
- package/dist/city/radar.d.ts +0 -0
- package/dist/city/radar.js +0 -0
- package/dist/city/scanning.d.ts +0 -0
- package/dist/city/scanning.js +0 -0
- package/dist/city/surroundLine.d.ts +0 -0
- package/dist/city/surroundLine.js +0 -0
- package/dist/core/mouseDrawe.d.ts +2 -0
- package/dist/core/mouseDrawe.js +1 -0
- package/dist/environment/cloud/cloud.d.ts +1 -0
- package/dist/environment/cloud/cloud.js +1 -0
- package/dist/environment/cloud/index.d.ts +7 -0
- package/dist/environment/cloud/index.js +60 -0
- package/dist/environment/rain.d.ts +20 -0
- package/dist/environment/rain.js +44 -0
- package/dist/environment/rainShder/index.d.ts +8 -0
- package/dist/environment/rainShder/index.js +70 -0
- package/dist/environment/rainShder/shader.d.ts +26 -0
- package/dist/environment/rainShder/shader.js +28 -0
- package/dist/environment/shaderCloud/cloudMaterial.d.ts +10 -0
- package/dist/environment/shaderCloud/cloudMaterial.js +39 -0
- package/dist/environment/shaderCloud/index.d.ts +2 -0
- package/dist/environment/shaderCloud/index.js +45 -0
- package/dist/environment/shaderCloud/shader.d.ts +5 -0
- package/dist/environment/shaderCloud/shader.js +6 -0
- package/dist/environment/showShder/index.d.ts +8 -0
- package/dist/environment/showShder/index.js +73 -0
- package/dist/environment/showShder/shader.d.ts +28 -0
- package/dist/environment/showShder/shader.js +32 -0
- package/dist/environment/sky/index.d.ts +12 -0
- package/dist/environment/sky/index.js +116 -0
- package/dist/environment/snow.d.ts +16 -0
- package/dist/environment/snow.js +45 -0
- package/dist/environment/sun/index.d.ts +13 -0
- package/dist/environment/sun/index.js +76 -0
- package/dist/environment/utils/points.d.ts +26 -0
- package/dist/environment/utils/points.js +55 -0
- package/dist/environment/volumetricCloud/cloudMaterial.d.ts +3 -0
- package/dist/environment/volumetricCloud/cloudMaterial.js +60 -0
- package/dist/environment/volumetricCloud/inex.d.ts +8 -0
- package/dist/environment/volumetricCloud/inex.js +42 -0
- package/dist/helper/view/index.d.ts +40 -0
- package/dist/helper/view/index.js +385 -0
- package/dist/helper/view/utils.d.ts +6 -0
- package/dist/helper/view/utils.js +91 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +20 -0
- package/dist/material/pristineGridMaterial/index.d.ts +20 -0
- package/dist/material/pristineGridMaterial/index.js +102 -0
- package/dist/material/pristineGridMaterial/shader/fragment.d.ts +2 -0
- package/dist/material/pristineGridMaterial/shader/fragment.js +1 -0
- package/dist/material/pristineGridMaterial/shader/vertex.d.ts +2 -0
- package/dist/material/pristineGridMaterial/shader/vertex.js +1 -0
- package/dist/postEffects/bloomPass.d.ts +5 -0
- package/dist/postEffects/bloomPass.js +30 -0
- package/dist/postEffects/index.d.ts +11 -0
- package/dist/postEffects/index.js +32 -0
- package/dist/postEffects/outlinePass.d.ts +16 -0
- package/dist/postEffects/outlinePass.js +51 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +3 -0
- package/package.json +29 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default /* glsl */"\nprecision highp float;\n\n// Varyings from the vertex shader\nin vec2 v_uv;\nin vec2 v_worldPos;\n\n// Uniforms\nuniform float u_majorLineWidth, u_minorLineWidth, u_axisLineWidth;\nuniform vec3 u_majorLineColor, u_minorLineColor, u_baseColor;\nuniform vec3 u_xAxisColor, u_zAxisColor;\nuniform float u_majorGridDiv, u_baseAlpha;\nuniform vec2 u_resolution;\n\n// Output color\nout vec4 gColor;\n\nfloat saturate(float value) {\nreturn clamp(value, 0.0, 1.0);\n}\n\nvoid main() {\n // Calculate derivatives for anti-aliasing\nvec4 uvDDXY = vec4(dFdx(v_uv), dFdy(v_uv));\nvec2 uvDeriv = vec2(length(uvDDXY.xz), length(uvDDXY.yw));\n\nvec4 worldPosDDXY = vec4(dFdx(v_worldPos), dFdy(v_worldPos));\nvec2 worldPosDeriv = vec2(length(worldPosDDXY.xz), length(worldPosDDXY.yw));\n\n // Axis lines calculation\nfloat axisLineWidth = max(u_majorLineWidth, u_axisLineWidth);\n\nvec2 axisDrawWidth = vec2(axisLineWidth) + worldPosDeriv * 0.5; // Adjust for AA\nvec2 axisLineAA = worldPosDeriv * 1.5;\nvec2 axisLines2 = smoothstep(axisDrawWidth + axisLineAA, axisDrawWidth - axisLineAA, abs(v_worldPos.xy * 2.0));\naxisLines2 *= (axisLineWidth / axisDrawWidth);\n\n // Major grid lines\nfloat div = max(2.0, round(u_majorGridDiv));\nvec2 majorUVDeriv = worldPosDeriv / div;\nfloat majorLineWidth = u_majorLineWidth / div;\nvec2 majorDrawWidth = clamp(vec2(majorLineWidth), majorUVDeriv, vec2(0.5));\nvec2 majorLineAA = majorUVDeriv * 1.5;\nvec2 majorGridUV = 1.0 - abs(fract(v_worldPos.xy / div) * 2.0 - 1.0);\nvec2 majorGrid2 = smoothstep(majorDrawWidth + majorLineAA, majorDrawWidth - majorLineAA, majorGridUV);\nmajorGrid2 *= (majorLineWidth / majorDrawWidth);\n\n // Minor grid lines\nfloat minorLineWidth = u_minorLineWidth;\nbool minorInvertLine = minorLineWidth > 0.5;\nfloat minorTargetWidth = minorInvertLine ? 1.0 - minorLineWidth : minorLineWidth;\nvec2 minorDrawWidth = clamp(vec2(minorTargetWidth), uvDeriv, vec2(0.5));\nvec2 minorLineAA = uvDeriv * 1.5;\nvec2 minorGridUV = abs(fract(v_uv) * 2.0 - 1.0);\nminorGridUV = minorInvertLine ? minorGridUV : 1.0 - minorGridUV;\nvec2 minorGrid2 = smoothstep(minorDrawWidth + minorLineAA, minorDrawWidth - minorLineAA, minorGridUV);\nminorGrid2 *= (minorTargetWidth / minorDrawWidth);\n\nif(max(axisLines2.x, axisLines2.y) > 0.) {\n // If we're drawing axis lines, don't draw grid lines on axis\nmajorGrid2 = vec2(0.);\nminorGrid2 = vec2(0.);\n}\n\n // Combine minor and major grid lines\nfloat minorGrid = mix(minorGrid2.x, 1.0, minorGrid2.y);\nfloat majorGrid = mix(majorGrid2.x, 1.0, majorGrid2.y);\n\n // Final color calculations for grid\nvec3 gridColor = mix(u_baseColor, u_minorLineColor, minorGrid);\ngridColor = mix(gridColor, u_majorLineColor, majorGrid);\nfloat gridAlpha = u_baseAlpha;\n\n // Apply base alpha to the grid lines\nif(minorGrid > 0.0) {\ngridAlpha = saturate(mix(gridAlpha, 1.0, minorGrid));\n}\nif(majorGrid > 0.0) {\ngridAlpha = saturate(mix(gridAlpha, 1.0, majorGrid));\n}\n\n // Apply axis color to the axis lines\nvec3 axisColor = mix(vec3(1.), u_xAxisColor, step(0.5, abs(v_worldPos.x)));\naxisColor = mix(axisColor, u_zAxisColor, step(0.5, abs(v_worldPos.y)));\n\nvec3 finalColor = mix(gridColor, axisColor, max(axisLines2.x, axisLines2.y));\n\nif(max(axisLines2.x, axisLines2.y) > 0.) {\ngridAlpha = saturate(mix(gridAlpha, 1.0, max(axisLines2.x, axisLines2.y)));\n}\n\n // Set the final fragment color\ngColor = vec4(finalColor, gridAlpha);\n}\n";
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
declare const _default: "\n\nprecision highp float;\n\n// Uniforms\nuniform float u_majorGridDiv;\nuniform float u_gridDiv;\n\nout vec2 v_uv; // Passed to the fragment shader\nout vec2 v_worldPos;\nvoid main() {\n vec4 transformed = vec4(position, 1.0);\n gl_Position = projectionMatrix * viewMatrix * modelMatrix * transformed;\n\n vec3 worldPosition = (modelMatrix * transformed).xyz;\n\n v_worldPos = worldPosition.xz * u_gridDiv;\n\n // Use local position for grid calculations\n vec3 localPos = transformed.xyz;\n vec3 cameraCenteringOffset = floor(cameraPosition);\n vec3 cameraSnappedWorldPos = worldPosition.xyz - cameraCenteringOffset;\n v_uv = cameraSnappedWorldPos.xz * u_gridDiv;\n\n}\n";
|
|
2
|
+
export default _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default /* glsl */"\n\nprecision highp float;\n\n// Uniforms\nuniform float u_majorGridDiv;\nuniform float u_gridDiv;\n\nout vec2 v_uv; // Passed to the fragment shader\nout vec2 v_worldPos;\nvoid main() {\n vec4 transformed = vec4(position, 1.0);\n gl_Position = projectionMatrix * viewMatrix * modelMatrix * transformed;\n\n vec3 worldPosition = (modelMatrix * transformed).xyz;\n\n v_worldPos = worldPosition.xz * u_gridDiv;\n\n // Use local position for grid calculations\n vec3 localPos = transformed.xyz;\n vec3 cameraCenteringOffset = floor(cameraPosition);\n vec3 cameraSnappedWorldPos = worldPosition.xyz - cameraCenteringOffset;\n v_uv = cameraSnappedWorldPos.xz * u_gridDiv;\n\n}\n";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Layers, use, utils } from '@anov/3d-core';
|
|
2
|
+
import { BlendFunction, EffectPass, KernelSize, SelectiveBloomEffect } from 'postprocessing';
|
|
3
|
+
var storeManagement = utils.storeManagement;
|
|
4
|
+
var useScene = use.useScene;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* create bloom selected
|
|
8
|
+
*/
|
|
9
|
+
var createBloomSelected = function createBloomSelected() {
|
|
10
|
+
var _useScene = useScene(),
|
|
11
|
+
scene = _useScene.scene,
|
|
12
|
+
camera = _useScene.camera;
|
|
13
|
+
var composer = storeManagement.get('composer');
|
|
14
|
+
if (!scene || !camera) throw new Error('scene or camera is not defined,');
|
|
15
|
+
if (!composer) throw new Error('composer is not defined, please initPostEffects first');
|
|
16
|
+
var bloomLayer = new Layers();
|
|
17
|
+
bloomLayer.set(1);
|
|
18
|
+
var bloomEffect = new SelectiveBloomEffect(scene, camera, {
|
|
19
|
+
blendFunction: BlendFunction.COLOR_DODGE,
|
|
20
|
+
kernelSize: KernelSize.SMALL,
|
|
21
|
+
luminanceThreshold: 0.9,
|
|
22
|
+
luminanceSmoothing: 0.0,
|
|
23
|
+
height: 480
|
|
24
|
+
});
|
|
25
|
+
bloomEffect.inverted = true;
|
|
26
|
+
var effectPass = new EffectPass(camera, bloomEffect);
|
|
27
|
+
composer.addPass(effectPass);
|
|
28
|
+
return function () {};
|
|
29
|
+
};
|
|
30
|
+
export default createBloomSelected;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Camera, Scene, WebGLRenderer } from '@anov/3d-core';
|
|
2
|
+
/**
|
|
3
|
+
* init post effects
|
|
4
|
+
* @param scene
|
|
5
|
+
* @param renderer
|
|
6
|
+
* @param camera
|
|
7
|
+
* @param beforehooks composer render before hook
|
|
8
|
+
* @param afterhooks composer render after hook
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
export declare const initPostEffects: (scene: Scene, renderer: WebGLRenderer, camera: Camera, beforehooks?: () => void, afterhooks?: () => void) => () => void;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { lib, use, utils } from '@anov/3d-core';
|
|
2
|
+
var EffectComposer = lib.EffectComposer,
|
|
3
|
+
RenderPass = lib.RenderPass;
|
|
4
|
+
var storeManagement = utils.storeManagement;
|
|
5
|
+
var useframe = use.useframe;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* init post effects
|
|
9
|
+
* @param scene
|
|
10
|
+
* @param renderer
|
|
11
|
+
* @param camera
|
|
12
|
+
* @param beforehooks composer render before hook
|
|
13
|
+
* @param afterhooks composer render after hook
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
export var initPostEffects = function initPostEffects(scene, renderer, camera, beforehooks, afterhooks) {
|
|
17
|
+
var composer = new EffectComposer(renderer);
|
|
18
|
+
var renderPass = new RenderPass(scene, camera);
|
|
19
|
+
storeManagement.set('composer', composer);
|
|
20
|
+
composer.addPass(renderPass);
|
|
21
|
+
storeManagement.set('renderPass', renderPass);
|
|
22
|
+
var cleanEffectsframe = useframe(function () {
|
|
23
|
+
beforehooks && beforehooks();
|
|
24
|
+
composer.render();
|
|
25
|
+
afterhooks && afterhooks();
|
|
26
|
+
});
|
|
27
|
+
return function () {
|
|
28
|
+
storeManagement.delete('composer');
|
|
29
|
+
storeManagement.delete('renderPass');
|
|
30
|
+
cleanEffectsframe();
|
|
31
|
+
};
|
|
32
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Object3D } from '@anov/3d-core';
|
|
2
|
+
declare type HighParamsType = {
|
|
3
|
+
edgeStrength?: number;
|
|
4
|
+
edgeGlow?: number;
|
|
5
|
+
edgeThickness?: number;
|
|
6
|
+
pulsePeriod?: number;
|
|
7
|
+
visibleEdgeColor?: string;
|
|
8
|
+
hiddenEdgeColor?: string;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
*
|
|
12
|
+
* @param highParams
|
|
13
|
+
* @returns
|
|
14
|
+
*/
|
|
15
|
+
declare const createHighSelectedTool: (highParams?: HighParamsType) => (object3dArray: Object3D[]) => void;
|
|
16
|
+
export default createHighSelectedTool;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
7
|
+
import { OutlinePassExtend, Vector2, lib, use, utils } from '@anov/3d-core';
|
|
8
|
+
var storeManagement = utils.storeManagement;
|
|
9
|
+
var ShaderPass = lib.ShaderPass,
|
|
10
|
+
FXAAShader = lib.FXAAShader;
|
|
11
|
+
var useScene = use.useScene;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
*
|
|
15
|
+
* @param highParams
|
|
16
|
+
* @returns
|
|
17
|
+
*/
|
|
18
|
+
var createHighSelectedTool = function createHighSelectedTool(highParams) {
|
|
19
|
+
var baseHighParams = {
|
|
20
|
+
edgeStrength: 10,
|
|
21
|
+
edgeGlow: 1,
|
|
22
|
+
edgeThickness: 3,
|
|
23
|
+
visibleEdgeColor: 'red',
|
|
24
|
+
hiddenEdgeColor: 'red'
|
|
25
|
+
};
|
|
26
|
+
var lastHighParams = _objectSpread(_objectSpread({}, baseHighParams), highParams);
|
|
27
|
+
var _useScene = useScene(),
|
|
28
|
+
scene = _useScene.scene,
|
|
29
|
+
camera = _useScene.camera;
|
|
30
|
+
var composer = storeManagement.get('composer');
|
|
31
|
+
if (!scene || !camera) throw new Error('scene or camera is not defined,');
|
|
32
|
+
if (!composer) throw new Error('composer is not defined, please initPostEffects first');
|
|
33
|
+
var outlinePass = new OutlinePassExtend(new Vector2(window.innerWidth, window.innerHeight), scene, camera);
|
|
34
|
+
outlinePass.edgeStrength = lastHighParams.edgeStrength;
|
|
35
|
+
outlinePass.edgeGlow = lastHighParams.edgeGlow;
|
|
36
|
+
outlinePass.edgeThickness = lastHighParams.edgeThickness;
|
|
37
|
+
lastHighParams.pulsePeriod && (outlinePass.pulsePeriod = lastHighParams.pulsePeriod);
|
|
38
|
+
outlinePass.visibleEdgeColor.set(lastHighParams.visibleEdgeColor);
|
|
39
|
+
composer.addPass(outlinePass);
|
|
40
|
+
|
|
41
|
+
// todo bugfix
|
|
42
|
+
// const effectFXAA = new ShaderPass(FXAAShader)
|
|
43
|
+
// effectFXAA.uniforms.resolution.value.set(1 / window.innerWidth, 1 / window.innerHeight)
|
|
44
|
+
// effectFXAA.renderToScreen = true
|
|
45
|
+
// composer.addPass(effectFXAA)
|
|
46
|
+
|
|
47
|
+
return function (object3dArray) {
|
|
48
|
+
outlinePass.selectedObjects = object3dArray;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
export default createHighSelectedTool;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getLastValue: <T>(optsValue: T | null | undefined, value: T) => T;
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@anov/3d-ability",
|
|
3
|
+
"version": "0.0.4-alpha1",
|
|
4
|
+
"description": "",
|
|
5
|
+
"author": "",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"keywords": [],
|
|
8
|
+
"module": "dist/index.js",
|
|
9
|
+
"types": "dist/index.d.ts",
|
|
10
|
+
"publishConfig": {
|
|
11
|
+
"access": "public"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"dist",
|
|
15
|
+
"readme.md",
|
|
16
|
+
"package.json"
|
|
17
|
+
],
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@types/suncalc": "^1.9.2",
|
|
20
|
+
"postprocessing": "^6.33.3",
|
|
21
|
+
"suncalc": "^1.9.0",
|
|
22
|
+
"@anov/3d-core": "^0.0.4-alpha13"
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "father build",
|
|
26
|
+
"build:deps": "father prebundle",
|
|
27
|
+
"test": "jest --maxWorkers 2"
|
|
28
|
+
}
|
|
29
|
+
}
|