w-threejs-vue 1.0.0
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/.editorconfig +9 -0
- package/.eslintignore +3 -0
- package/.eslintrc.js +55 -0
- package/.jsdoc +25 -0
- package/LICENSE +21 -0
- package/README.md +39 -0
- package/SECURITY.md +5 -0
- package/babel.config.js +15 -0
- package/dist/w-threejs-vue.umd.js +26 -0
- package/dist/w-threejs-vue.umd.js.map +1 -0
- package/docs/examples/app.html +66 -0
- package/docs/examples/app.umd.js +31 -0
- package/docs/examples/app.umd.js.map +1 -0
- package/docs/examples/ex-AppBasicAutoRotateDeg.html +190 -0
- package/docs/examples/ex-AppBasicBackgroundColor.html +189 -0
- package/docs/examples/ex-AppBasicSize.html +170 -0
- package/docs/examples/ex-AppBasicUploadStl.html +237 -0
- package/docs/examples/ex-AppBasicUseAutoRotate.html +189 -0
- package/docs/examples/ex-AppCmCameraFar.html +191 -0
- package/docs/examples/ex-AppCmCameraFov.html +191 -0
- package/docs/examples/ex-AppCmCameraNear.html +191 -0
- package/docs/examples/ex-AppCmCameraOrthographicRatio.html +191 -0
- package/docs/examples/ex-AppCmCameraType.html +190 -0
- package/docs/examples/ex-AppCmGetCameraViewAngle.html +218 -0
- package/docs/examples/ex-AppCmSetCameraAzimuthAngle.html +190 -0
- package/docs/examples/ex-AppCmSetCameraPolarAngle.html +190 -0
- package/docs/examples/ex-AppCmSetCameraViewAngle.html +194 -0
- package/docs/examples/ex-AppHpHelperAxesLengthRatio.html +189 -0
- package/docs/examples/ex-AppHpHelperGridDensity.html +189 -0
- package/docs/examples/ex-AppHpHelperGridLengthRatio.html +189 -0
- package/docs/examples/ex-AppHpHelperGridPositionRatioZ.html +189 -0
- package/docs/examples/ex-AppHpUseHelperAxes.html +189 -0
- package/docs/examples/ex-AppHpUseHelperGrid.html +189 -0
- package/docs/examples/ex-AppLgLegnedBackgroundColor.html +189 -0
- package/docs/examples/ex-AppLgLegnedHeight.html +189 -0
- package/docs/examples/ex-AppLgLegnedHeightMax.html +189 -0
- package/docs/examples/ex-AppLtLightAmbientColor.html +189 -0
- package/docs/examples/ex-AppLtLightDirectionColor.html +191 -0
- package/docs/examples/ex-AppLtLightDirectionIntensity.html +191 -0
- package/docs/examples/ex-AppLtLightDirectionPos.html +191 -0
- package/docs/examples/ex-AppLtLightPointColor.html +192 -0
- package/docs/examples/ex-AppLtLightPointDecay.html +192 -0
- package/docs/examples/ex-AppLtLightPointDistance.html +192 -0
- package/docs/examples/ex-AppLtLightPointIntensity.html +192 -0
- package/docs/examples/ex-AppLtLightPointPoss.html +192 -0
- package/docs/examples/ex-AppLtUseLightAmbient.html +191 -0
- package/docs/examples/ex-AppLtUseLightDirection.html +191 -0
- package/docs/examples/ex-AppLtUseLightPoint.html +191 -0
- package/docs/examples/ex-AppMhGetMeshsInfor.html +198 -0
- package/docs/examples/ex-AppMhSetMeshColor.html +190 -0
- package/docs/examples/ex-AppMhSetMeshLabelText.html +190 -0
- package/docs/examples/ex-AppMhSetMeshLabelTextColor.html +190 -0
- package/docs/examples/ex-AppMhSetMeshLabelTextFontFamily.html +190 -0
- package/docs/examples/ex-AppMhSetMeshLabelTextFontSize.html +190 -0
- package/docs/examples/ex-AppMhSetMeshLabelVisible.html +198 -0
- package/docs/examples/ex-AppMhSetMeshVisible.html +198 -0
- package/docs/examples/ex-AppMuMenuIcons.html +217 -0
- package/docs/examples/ex-AppMuMenuTooltips.html +218 -0
- package/docs/fonts/Montserrat/Montserrat-Bold.eot +0 -0
- package/docs/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
- package/docs/fonts/Montserrat/Montserrat-Bold.woff +0 -0
- package/docs/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.eot +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.woff +0 -0
- package/docs/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +978 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +1049 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
- package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
- package/docs/index.html +84 -0
- package/docs/module-WThreejsVue.html +216 -0
- package/docs/scripts/collapse.js +39 -0
- package/docs/scripts/commonNav.js +28 -0
- package/docs/scripts/linenumber.js +25 -0
- package/docs/scripts/nav.js +12 -0
- package/docs/scripts/polyfill.js +4 -0
- package/docs/scripts/prettify/Apache-License-2.0.txt +202 -0
- package/docs/scripts/prettify/lang-css.js +2 -0
- package/docs/scripts/prettify/prettify.js +28 -0
- package/docs/scripts/search.js +99 -0
- package/docs/styles/jsdoc.css +776 -0
- package/docs/styles/prettify.css +80 -0
- package/package.json +74 -0
- package/public/index.html +42 -0
- package/src/App.vue +574 -0
- package/src/AppBasicAutoRotateDeg.vue +102 -0
- package/src/AppBasicBackgroundColor.vue +101 -0
- package/src/AppBasicSize.vue +90 -0
- package/src/AppBasicUploadStl.vue +159 -0
- package/src/AppBasicUseAutoRotate.vue +101 -0
- package/src/AppCmCameraFar.vue +103 -0
- package/src/AppCmCameraFov.vue +103 -0
- package/src/AppCmCameraNear.vue +103 -0
- package/src/AppCmCameraOrthographicRatio.vue +103 -0
- package/src/AppCmCameraType.vue +102 -0
- package/src/AppCmGetCameraViewAngle.vue +135 -0
- package/src/AppCmSetCameraAzimuthAngle.vue +104 -0
- package/src/AppCmSetCameraPolarAngle.vue +104 -0
- package/src/AppCmSetCameraViewAngle.vue +105 -0
- package/src/AppHpHelperAxesLengthRatio.vue +101 -0
- package/src/AppHpHelperGridDensity.vue +101 -0
- package/src/AppHpHelperGridLengthRatio.vue +101 -0
- package/src/AppHpHelperGridPositionRatioZ.vue +101 -0
- package/src/AppHpUseHelperAxes.vue +101 -0
- package/src/AppHpUseHelperGrid.vue +101 -0
- package/src/AppLgLegnedBackgroundColor.vue +101 -0
- package/src/AppLgLegnedHeight.vue +101 -0
- package/src/AppLgLegnedHeightMax.vue +101 -0
- package/src/AppLtLightAmbientColor.vue +101 -0
- package/src/AppLtLightDirectionColor.vue +103 -0
- package/src/AppLtLightDirectionIntensity.vue +103 -0
- package/src/AppLtLightDirectionPos.vue +103 -0
- package/src/AppLtLightPointColor.vue +104 -0
- package/src/AppLtLightPointDecay.vue +104 -0
- package/src/AppLtLightPointDistance.vue +104 -0
- package/src/AppLtLightPointIntensity.vue +104 -0
- package/src/AppLtLightPointPoss.vue +104 -0
- package/src/AppLtUseLightAmbient.vue +103 -0
- package/src/AppLtUseLightDirection.vue +103 -0
- package/src/AppLtUseLightPoint.vue +103 -0
- package/src/AppMhGetMeshsInfor.vue +112 -0
- package/src/AppMhSetMeshColor.vue +104 -0
- package/src/AppMhSetMeshLabelText.vue +104 -0
- package/src/AppMhSetMeshLabelTextColor.vue +104 -0
- package/src/AppMhSetMeshLabelTextFontFamily.vue +104 -0
- package/src/AppMhSetMeshLabelTextFontSize.vue +104 -0
- package/src/AppMhSetMeshLabelVisible.vue +106 -0
- package/src/AppMhSetMeshVisible.vue +106 -0
- package/src/AppMuMenuIcons.vue +130 -0
- package/src/AppMuMenuTooltips.vue +131 -0
- package/src/components/WThreejsVue.vue +955 -0
- package/src/js/addStl.mjs +83 -0
- package/src/js/getCsrdFromMeshs.mjs +85 -0
- package/src/js/plot3d.mjs +1407 -0
- package/src/main.js +8 -0
- package/test/all.test.mjs +10 -0
- package/toolg/addVersion.mjs +4 -0
- package/toolg/cleanFolder.mjs +4 -0
- package/toolg/gDistApp.mjs +38 -0
- package/toolg/gDistRollupComps.mjs +22 -0
- package/toolg/gDocExams.mjs +47 -0
- package/toolg/gExtractHtml.mjs +159 -0
- package/toolg/modifyReadme.mjs +4 -0
- package/vue.config.js +21 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import get from 'lodash-es/get'
|
|
2
|
+
import isNumber from 'lodash-es/isNumber'
|
|
3
|
+
import isestr from 'wsemi/src/isestr.mjs'
|
|
4
|
+
import oc from 'wsemi/src/color.mjs'
|
|
5
|
+
import * as THREE from 'three'
|
|
6
|
+
import { STLLoader } from 'three/addons/loaders/STLLoader.js'
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
let addStl = async(ev, url, opt = {}) => {
|
|
10
|
+
|
|
11
|
+
//color
|
|
12
|
+
let color = get(opt, 'color', null)
|
|
13
|
+
if (!isestr(color)) {
|
|
14
|
+
color = '#fff'
|
|
15
|
+
}
|
|
16
|
+
color = oc.toRgbString(color)
|
|
17
|
+
// console.log('color', color)
|
|
18
|
+
|
|
19
|
+
//opacity
|
|
20
|
+
let opacity = get(opt, 'opacity', null)
|
|
21
|
+
if (!isNumber(opacity)) {
|
|
22
|
+
opacity = 1
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
//transparent
|
|
26
|
+
let transparent = opacity < 1
|
|
27
|
+
|
|
28
|
+
//loader
|
|
29
|
+
let loader = new STLLoader()
|
|
30
|
+
let geometry = await loader.loadAsync(url, (xhr) => {
|
|
31
|
+
let prog = (xhr.loaded / xhr.total) * 100
|
|
32
|
+
ev.emit('loading', {
|
|
33
|
+
url,
|
|
34
|
+
prog,
|
|
35
|
+
})
|
|
36
|
+
})
|
|
37
|
+
// console.log('geometry', geometry)
|
|
38
|
+
|
|
39
|
+
//material, MeshLambertMaterial, MeshPhysicalMaterial
|
|
40
|
+
let material = new THREE.MeshLambertMaterial({
|
|
41
|
+
|
|
42
|
+
// visible:false,
|
|
43
|
+
|
|
44
|
+
color: new THREE.Color(color),
|
|
45
|
+
// wireframe: true,
|
|
46
|
+
|
|
47
|
+
depthTest: true,
|
|
48
|
+
depthWrite: true,
|
|
49
|
+
|
|
50
|
+
transparent,
|
|
51
|
+
opacity,
|
|
52
|
+
|
|
53
|
+
side: THREE.DoubleSide,
|
|
54
|
+
|
|
55
|
+
// polygonOffset: true,
|
|
56
|
+
// polygonOffsetFactor: 1, // positive value pushes polygon further away
|
|
57
|
+
// polygonOffsetUnits: 1,
|
|
58
|
+
|
|
59
|
+
// //for MeshPhysicalMaterial
|
|
60
|
+
// clearcoat: 1.0,//物体表面清漆层或者说透明涂层的厚度
|
|
61
|
+
// clearcoatRoughness: 0.1,//透明涂层表面的粗糙度
|
|
62
|
+
// envMap: envTexture,
|
|
63
|
+
// metalness: 0.25,
|
|
64
|
+
// roughness: 0.1,
|
|
65
|
+
// transmission: 0.99,
|
|
66
|
+
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
//mesh
|
|
70
|
+
let mesh = new THREE.Mesh(geometry, material)
|
|
71
|
+
// console.log('mesh', mesh)
|
|
72
|
+
|
|
73
|
+
// // wireframe, 若要使用也需要座標平移
|
|
74
|
+
// var geo = new THREE.WireframeGeometry( geometry ); // or WireframeGeometry
|
|
75
|
+
// var mat = new THREE.LineBasicMaterial( { color: 0x000000 } );
|
|
76
|
+
// var wireframe = new THREE.LineSegments( geo, mat );
|
|
77
|
+
// mesh.add( wireframe )
|
|
78
|
+
|
|
79
|
+
return mesh
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
export default addStl
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import map from 'lodash-es/map'
|
|
2
|
+
import min from 'lodash-es/min'
|
|
3
|
+
import max from 'lodash-es/max'
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
let getCsrdFromMesh = (mesh) => {
|
|
7
|
+
// console.log('mesh',mesh)
|
|
8
|
+
let geometry = mesh.geometry
|
|
9
|
+
// console.log('geometry',geometry)
|
|
10
|
+
let cs = geometry.boundingSphere.center
|
|
11
|
+
// console.log('cs',cloneDeep(cs))
|
|
12
|
+
let rd = geometry.boundingSphere.radius
|
|
13
|
+
// console.log('rd',rd)
|
|
14
|
+
return {
|
|
15
|
+
cs,
|
|
16
|
+
rd,
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
let BoxFromMesh = (mesh) => {
|
|
22
|
+
let r = getCsrdFromMesh(mesh)
|
|
23
|
+
let xmin = r.cs.x - r.rd
|
|
24
|
+
let xmax = r.cs.x + r.rd
|
|
25
|
+
let ymin = r.cs.y - r.rd
|
|
26
|
+
let ymax = r.cs.y + r.rd
|
|
27
|
+
let zmin = r.cs.z - r.rd
|
|
28
|
+
let zmax = r.cs.z + r.rd
|
|
29
|
+
return {
|
|
30
|
+
xmin,
|
|
31
|
+
xmax,
|
|
32
|
+
ymin,
|
|
33
|
+
ymax,
|
|
34
|
+
zmin,
|
|
35
|
+
zmax,
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
let getBoxFromMeshs = (meshs) => {
|
|
41
|
+
let bxs = map(meshs, (mesh, kmesh) => {
|
|
42
|
+
// console.log('kmesh', kmesh, mesh)
|
|
43
|
+
let bx = BoxFromMesh(mesh)
|
|
44
|
+
// console.log('bx',bx)
|
|
45
|
+
return bx
|
|
46
|
+
})
|
|
47
|
+
let xmin = min(map(bxs, 'xmin'))
|
|
48
|
+
let xmax = max(map(bxs, 'xmax'))
|
|
49
|
+
let ymin = min(map(bxs, 'ymin'))
|
|
50
|
+
let ymax = max(map(bxs, 'ymax'))
|
|
51
|
+
let zmin = min(map(bxs, 'zmin'))
|
|
52
|
+
let zmax = max(map(bxs, 'zmax'))
|
|
53
|
+
return {
|
|
54
|
+
xmin,
|
|
55
|
+
xmax,
|
|
56
|
+
ymin,
|
|
57
|
+
ymax,
|
|
58
|
+
zmin,
|
|
59
|
+
zmax,
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
let getCsrdFromMeshs = (meshs) => {
|
|
65
|
+
let bx = getBoxFromMeshs(meshs)
|
|
66
|
+
// console.log('bx(all)',bx)
|
|
67
|
+
let xrng = bx.xmax - bx.xmin
|
|
68
|
+
let yrng = bx.ymax - bx.ymin
|
|
69
|
+
let zrng = bx.zmax - bx.zmin
|
|
70
|
+
let xc = (bx.xmax + bx.xmin) / 2
|
|
71
|
+
let yc = (bx.ymax + bx.ymin) / 2
|
|
72
|
+
let zc = (bx.zmax + bx.zmin) / 2
|
|
73
|
+
let rd = max([xrng, yrng, zrng])
|
|
74
|
+
return {
|
|
75
|
+
cs: {
|
|
76
|
+
x: xc,
|
|
77
|
+
y: yc,
|
|
78
|
+
z: zc,
|
|
79
|
+
},
|
|
80
|
+
rd,
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
export default getCsrdFromMeshs
|