@abi-software/scaffoldvuer 0.4.0-vue3.6 → 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/.eslintrc.js +4 -11
- package/README.md +2 -1
- package/dist/scaffoldvuer.js +17943 -17046
- package/dist/scaffoldvuer.umd.cjs +410 -182
- package/dist/style.css +1 -1
- package/package.json +18 -11
- package/src/App.vue +52 -7
- package/src/app/DropZone.vue +40 -3
- package/src/app/ModelsInformation.js +58 -48
- package/src/app/ModelsTable.vue +11 -11
- package/src/app/TextureDemos.js +123 -6
- package/src/components/OpacityControls.vue +2 -2
- package/src/components/PrimitiveControls.vue +8 -5
- package/src/components/ScaffoldTooltip.vue +9 -0
- package/src/components/ScaffoldVuer.vue +111 -35
- package/src/components/TextureSlidesControls.vue +47 -45
- package/src/components/TreeControls.vue +1 -1
- package/src/components.d.ts +2 -0
- package/src/main.js +14 -2
- package/src/scripts/GraphicsHighlight.js +64 -25
- package/src/scripts/OrgansRenderer.js +3 -7
- package/src/scripts/RendererModule.js +9 -15
- package/src/store/index.js +24 -0
- package/vite.config.js +12 -0
- package/vite.static-build.js +7 -1
- package/vuese-generator.js +65 -0
- package/styleguide.config.js +0 -22
package/src/main.js
CHANGED
|
@@ -1,17 +1,29 @@
|
|
|
1
1
|
import { createApp } from 'vue'
|
|
2
|
+
import { createPinia } from 'pinia'
|
|
2
3
|
import * as VueRouter from 'vue-router'
|
|
3
4
|
import App from './App.vue'
|
|
5
|
+
import { useMainStore } from '@/store/index'
|
|
4
6
|
|
|
5
7
|
const routes = [
|
|
6
8
|
{ path: '/'},
|
|
7
9
|
]
|
|
8
10
|
|
|
11
|
+
const app = createApp(App)
|
|
12
|
+
|
|
9
13
|
const router = VueRouter.createRouter({
|
|
10
14
|
// 4. Provide the history implementation to use. We are using the hash history for simplicity here.
|
|
11
15
|
history: VueRouter.createWebHashHistory(),
|
|
12
16
|
routes,
|
|
13
17
|
})
|
|
14
|
-
|
|
15
|
-
const app = createApp(App)
|
|
16
18
|
app.use(router)
|
|
19
|
+
const pinia = createPinia()
|
|
20
|
+
|
|
21
|
+
app.use(pinia)
|
|
22
|
+
|
|
23
|
+
const mainStore = useMainStore()
|
|
24
|
+
const token = document.cookie.split("; ").find((row) => row.startsWith("user-token"))
|
|
25
|
+
if (mainStore && token) {
|
|
26
|
+
mainStore.setUserToken(token.split("=")[1])
|
|
27
|
+
}
|
|
28
|
+
|
|
17
29
|
app.mount('#app')
|
|
@@ -1,4 +1,27 @@
|
|
|
1
1
|
import { THREE } from 'zincjs';
|
|
2
|
+
|
|
3
|
+
const setEmissiveColour = (fullList, colour, setDepthFunc) => {
|
|
4
|
+
for (let i = 0; i < fullList.length; i++) {
|
|
5
|
+
if (fullList[i] && fullList[i].material && fullList[i].material.emissive) {
|
|
6
|
+
let object = fullList[i].userData;
|
|
7
|
+
if (object && object.isZincObject) {
|
|
8
|
+
object.setEmissiveRGB(colour);
|
|
9
|
+
} else if (fullList[i].material && fullList[i].material.emissive) {
|
|
10
|
+
fullList[i].material.emissive.setRGB(...colour);
|
|
11
|
+
}
|
|
12
|
+
if (setDepthFunc && fullList[i].material.depthFunc) {
|
|
13
|
+
fullList[i].material.depthFunc = THREE.LessEqualDepth;
|
|
14
|
+
}
|
|
15
|
+
fullList[i].children.forEach(child => {
|
|
16
|
+
const object = child.userData;
|
|
17
|
+
if (object && object.isZincObject && child.material && child.material.emissive) {
|
|
18
|
+
child.material.emissive.setRGB(...colour);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
2
25
|
/**
|
|
3
26
|
* This module manages highlighted and selected objects in 3D modules.
|
|
4
27
|
*
|
|
@@ -57,17 +80,50 @@ const GraphicsHighlight = function() {
|
|
|
57
80
|
}
|
|
58
81
|
return _temp1;
|
|
59
82
|
}
|
|
60
|
-
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
/*
|
|
86
|
+
* Not sure why the following block does not work
|
|
87
|
+
*
|
|
61
88
|
this.setHighlighted = function(objects) {
|
|
62
89
|
const previousHighlightedObjects = [...currentHighlightedObjects];
|
|
63
|
-
_this.resetHighlighted();
|
|
64
90
|
// Selected object cannot be highlighted
|
|
65
91
|
const array = getUnmatchingObjects(objects, currentSelectedObjects);
|
|
66
92
|
const fullList = getFullListOfObjects(array);
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
93
|
+
const different = isDifferent(array, previousHighlightedObjects);
|
|
94
|
+
console.log("highlight:", different)
|
|
95
|
+
if (different) {
|
|
96
|
+
_this.resetHighlighted();
|
|
97
|
+
setEmissiveColour(fullList, _this.highlightColour, false);
|
|
98
|
+
}
|
|
99
|
+
currentHighlightedObjects = array;
|
|
100
|
+
return different;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
this.setSelected = function(objects) {
|
|
104
|
+
// first find highlighted object that are not selected
|
|
105
|
+
const previousHSelectedObjects = [...currentSelectedObjects];
|
|
106
|
+
const fullList = getFullListOfObjects(objects);
|
|
107
|
+
const different = isDifferent(objects, previousHSelectedObjects);
|
|
108
|
+
console.log("selected:", different)
|
|
109
|
+
if (different) {
|
|
110
|
+
_this.resetHighlighted();
|
|
111
|
+
_this.resetSelected();
|
|
112
|
+
setEmissiveColour(fullList, _this.selectColour, false);
|
|
70
113
|
}
|
|
114
|
+
currentSelectedObjects = objects;
|
|
115
|
+
return different;
|
|
116
|
+
}
|
|
117
|
+
*/
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
this.setHighlighted = function(objects) {
|
|
121
|
+
const previousHighlightedObjects = [...currentHighlightedObjects];
|
|
122
|
+
_this.resetHighlighted();
|
|
123
|
+
// Selected object cannot be highlighted
|
|
124
|
+
const array = getUnmatchingObjects(objects, currentSelectedObjects);
|
|
125
|
+
const fullList = getFullListOfObjects(array);
|
|
126
|
+
setEmissiveColour(fullList, _this.highlightColour, false);
|
|
71
127
|
currentHighlightedObjects = array;
|
|
72
128
|
return isDifferent(currentHighlightedObjects, previousHighlightedObjects);
|
|
73
129
|
}
|
|
@@ -79,10 +135,7 @@ const GraphicsHighlight = function() {
|
|
|
79
135
|
_this.resetHighlighted();
|
|
80
136
|
_this.resetSelected();
|
|
81
137
|
const fullList = getFullListOfObjects(objects);
|
|
82
|
-
|
|
83
|
-
if (fullList[i] && fullList[i].material && fullList[i].material.emissive)
|
|
84
|
-
fullList[i].material.emissive.setRGB(..._this.selectColour);
|
|
85
|
-
}
|
|
138
|
+
setEmissiveColour(fullList, _this.selectColour, false);
|
|
86
139
|
currentSelectedObjects = objects;
|
|
87
140
|
return isDifferent(currentSelectedObjects, previousHSelectedObjects);
|
|
88
141
|
}
|
|
@@ -98,27 +151,13 @@ const GraphicsHighlight = function() {
|
|
|
98
151
|
|
|
99
152
|
this.resetHighlighted = function() {
|
|
100
153
|
const fullList = getFullListOfObjects(currentHighlightedObjects);
|
|
101
|
-
|
|
102
|
-
if (fullList[i] && fullList[i].material) {
|
|
103
|
-
if (fullList[i].material.emissive)
|
|
104
|
-
fullList[i].material.emissive.setRGB(..._this.originalColour);
|
|
105
|
-
if (fullList[i].material.depthFunc)
|
|
106
|
-
fullList[i].material.depthFunc = THREE.LessEqualDepth;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
154
|
+
setEmissiveColour(fullList, _this.originalColour, true);
|
|
109
155
|
currentHighlightedObjects = [];
|
|
110
156
|
}
|
|
111
157
|
|
|
112
158
|
this.resetSelected = function() {
|
|
113
159
|
const fullList = getFullListOfObjects(currentSelectedObjects);
|
|
114
|
-
|
|
115
|
-
if (fullList[i] && fullList[i].material) {
|
|
116
|
-
if (fullList[i].material.emissive)
|
|
117
|
-
fullList[i].material.emissive.setRGB(..._this.originalColour);
|
|
118
|
-
if (fullList[i].material.depthFunc)
|
|
119
|
-
fullList[i].material.depthFunc = THREE.LessEqualDepth;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
160
|
+
setEmissiveColour(fullList, _this.originalColour, true);
|
|
122
161
|
currentSelectedObjects = [];
|
|
123
162
|
}
|
|
124
163
|
|
|
@@ -13,8 +13,8 @@ const OrgansSceneData = function() {
|
|
|
13
13
|
this.currentSpecies = "";
|
|
14
14
|
this.metaURL = "";
|
|
15
15
|
this.viewURL = "";
|
|
16
|
-
this.currentTime = 0.0;
|
|
17
16
|
this.timeVarying = false;
|
|
17
|
+
this.currentTime = 0.0;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
/**
|
|
@@ -43,8 +43,7 @@ const OrgansSceneData = function() {
|
|
|
43
43
|
const modelsLoader = ModelsLoaderIn;
|
|
44
44
|
this.NDCCameraControl = undefined;
|
|
45
45
|
_this.typeName = "Organ Viewer";
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
|
|
48
47
|
this.getSceneData = function() {
|
|
49
48
|
return _this.sceneData;
|
|
50
49
|
}
|
|
@@ -64,7 +63,6 @@ const OrgansSceneData = function() {
|
|
|
64
63
|
_this.scene.setMorphsTime(actualTime);
|
|
65
64
|
}
|
|
66
65
|
_this.sceneData.currentTime = value;
|
|
67
|
-
_this.currentTime = value;
|
|
68
66
|
}
|
|
69
67
|
|
|
70
68
|
/**
|
|
@@ -84,7 +82,6 @@ const OrgansSceneData = function() {
|
|
|
84
82
|
_this.sceneData.nerveMap.additionalReader.setTime(currentTime /
|
|
85
83
|
duration);
|
|
86
84
|
_this.sceneData.currentTime = currentTime / duration * 100.0;
|
|
87
|
-
_this.currentTime = currentTime / duration * 100.0;
|
|
88
85
|
}
|
|
89
86
|
|
|
90
87
|
this.getCurrentTime = function() {
|
|
@@ -204,7 +201,7 @@ const OrgansSceneData = function() {
|
|
|
204
201
|
if (intersected.object.userData &&
|
|
205
202
|
intersected.object.userData.isMarker) {
|
|
206
203
|
marker = true;
|
|
207
|
-
intersectedObject = intersected.object.userData.parent.
|
|
204
|
+
intersectedObject = intersected.object.userData.parent.getMorph();
|
|
208
205
|
} else {
|
|
209
206
|
intersectedObject = intersected.object;
|
|
210
207
|
}
|
|
@@ -463,7 +460,6 @@ const OrgansSceneData = function() {
|
|
|
463
460
|
_this.sceneData.currentPart = partName;
|
|
464
461
|
_this.sceneData.currentTime = 0.0;
|
|
465
462
|
_this.sceneData.timeVarying = false;
|
|
466
|
-
_this.currentTime = 0.0;
|
|
467
463
|
// This is used as title
|
|
468
464
|
let name = "";
|
|
469
465
|
if (speciesName)
|
|
@@ -114,8 +114,8 @@ RendererModule.prototype.setHighlightedByZincObjects = function(
|
|
|
114
114
|
let morphs = [];
|
|
115
115
|
if (zincObjects) {
|
|
116
116
|
zincObjects.forEach(zincObject => {
|
|
117
|
-
if (zincObject && zincObject.
|
|
118
|
-
morphs.push(zincObject.
|
|
117
|
+
if (zincObject && zincObject.getMorph())
|
|
118
|
+
morphs.push(zincObject.getMorph());
|
|
119
119
|
});
|
|
120
120
|
}
|
|
121
121
|
|
|
@@ -179,8 +179,12 @@ RendererModule.prototype.setSelectedByZincObjects = function(
|
|
|
179
179
|
let morphs = [];
|
|
180
180
|
if (zincObjects) {
|
|
181
181
|
zincObjects.forEach(zincObject => {
|
|
182
|
-
if (zincObject
|
|
183
|
-
|
|
182
|
+
if (zincObject) {
|
|
183
|
+
const morph = zincObject.getMorph();
|
|
184
|
+
if (morph) {
|
|
185
|
+
morphs.push(morph);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
184
188
|
});
|
|
185
189
|
}
|
|
186
190
|
|
|
@@ -194,17 +198,7 @@ const addGlyphToArray = function(objects) {
|
|
|
194
198
|
}
|
|
195
199
|
|
|
196
200
|
RendererModule.prototype.findObjectsByGroupName = function(groupName) {
|
|
197
|
-
|
|
198
|
-
const objects = [];
|
|
199
|
-
for (let i = 0; i < geometries.length; i ++ ) {
|
|
200
|
-
objects.push(geometries[i].morph);
|
|
201
|
-
}
|
|
202
|
-
const glyphsets = this.scene.findGlyphsetsWithGroupName(groupName);
|
|
203
|
-
for (let i = 0; i < glyphsets.length; i ++ ) {
|
|
204
|
-
glyphsets[i].forEachGlyph(addGlyphToArray(objects));
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
return objects;
|
|
201
|
+
return this.scene.findObjectsWithGroupName(groupName);
|
|
208
202
|
}
|
|
209
203
|
|
|
210
204
|
RendererModule.prototype.setHighlightedByGroupName = function(groupName, propagateChanges) {
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { defineStore } from 'pinia'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Activate the store when run the application individually.
|
|
5
|
+
* If the store exist in parent application,
|
|
6
|
+
* instead of creating a new store it will access the parent main store.
|
|
7
|
+
*/
|
|
8
|
+
export const useMainStore = defineStore('main', {
|
|
9
|
+
state: () => ({
|
|
10
|
+
userProfile: {
|
|
11
|
+
token: ''
|
|
12
|
+
},
|
|
13
|
+
}),
|
|
14
|
+
getters: {
|
|
15
|
+
userToken(state) {
|
|
16
|
+
return state.userProfile.token
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
actions: {
|
|
20
|
+
setUserToken(value) {
|
|
21
|
+
this.userProfile.token = value
|
|
22
|
+
},
|
|
23
|
+
}
|
|
24
|
+
})
|
package/vite.config.js
CHANGED
|
@@ -4,6 +4,7 @@ import { defineConfig } from 'vite'
|
|
|
4
4
|
import vue from '@vitejs/plugin-vue'
|
|
5
5
|
import Components from 'unplugin-vue-components/vite'
|
|
6
6
|
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
|
|
7
|
+
import { nodePolyfills } from 'vite-plugin-node-polyfills'
|
|
7
8
|
|
|
8
9
|
// https://vitejs.dev/config/
|
|
9
10
|
export default defineConfig(({ command, mode }) => {
|
|
@@ -33,6 +34,11 @@ export default defineConfig(({ command, mode }) => {
|
|
|
33
34
|
// https://github.com/antfu/unocss
|
|
34
35
|
// see unocss.config.ts for config
|
|
35
36
|
],
|
|
37
|
+
resolve: {
|
|
38
|
+
alias: {
|
|
39
|
+
'@': path.resolve(__dirname, './src'),
|
|
40
|
+
}
|
|
41
|
+
},
|
|
36
42
|
build: {
|
|
37
43
|
lib: {
|
|
38
44
|
entry: path.resolve(__dirname, "./src/components/index.js"),
|
|
@@ -62,6 +68,12 @@ export default defineConfig(({ command, mode }) => {
|
|
|
62
68
|
// If you want to exposes all env variables, which is not recommended
|
|
63
69
|
// 'process.env': env
|
|
64
70
|
};
|
|
71
|
+
config.plugins.push(
|
|
72
|
+
nodePolyfills({
|
|
73
|
+
// To add only specific polyfills, add them here. If no option is passed, adds all polyfills
|
|
74
|
+
include: ['path']
|
|
75
|
+
})
|
|
76
|
+
);
|
|
65
77
|
};
|
|
66
78
|
return config;
|
|
67
79
|
})
|
package/vite.static-build.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { defineConfig } from 'vite'
|
|
2
2
|
import rootConfig from './vite.config.js'
|
|
3
|
+
import { nodePolyfills } from 'vite-plugin-node-polyfills'
|
|
3
4
|
|
|
4
5
|
// defineWorkspace provides a nice type hinting DX
|
|
5
6
|
export default defineConfig((configEnv) => {
|
|
@@ -7,6 +8,11 @@ export default defineConfig((configEnv) => {
|
|
|
7
8
|
config.build = {
|
|
8
9
|
outDir: "test-html"
|
|
9
10
|
};
|
|
10
|
-
|
|
11
|
+
config.plugins.push(
|
|
12
|
+
nodePolyfills({
|
|
13
|
+
// To add only specific polyfills, add them here. If no option is passed, adds all polyfills
|
|
14
|
+
include: ['path']
|
|
15
|
+
})
|
|
16
|
+
);
|
|
11
17
|
return config;
|
|
12
18
|
})
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vuese Generator
|
|
3
|
+
*
|
|
4
|
+
* To generate markdown files from Vue components
|
|
5
|
+
* To watch components changes for Vitepress on Dev Mode
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import fs from 'fs'
|
|
9
|
+
import path from 'path'
|
|
10
|
+
import chokidar from 'chokidar'
|
|
11
|
+
import { parser } from '@vuese/parser'
|
|
12
|
+
import { Render } from '@vuese/markdown-render'
|
|
13
|
+
|
|
14
|
+
const watchMode = process.argv.find((argv) => argv === 'watch')
|
|
15
|
+
|
|
16
|
+
const componentsDir = 'src/components'
|
|
17
|
+
const components = ['ScaffoldVuer.vue']
|
|
18
|
+
const outputDir = 'docs/components'
|
|
19
|
+
|
|
20
|
+
function generateMarkdown(file) {
|
|
21
|
+
const fileWithPath = `${componentsDir}/${file}`
|
|
22
|
+
const fileContent = fs.readFileSync(fileWithPath, 'utf-8')
|
|
23
|
+
|
|
24
|
+
try {
|
|
25
|
+
const parserResult = parser(fileContent)
|
|
26
|
+
const r = new Render(parserResult)
|
|
27
|
+
const renderResult = r.render()
|
|
28
|
+
const markdownResult = r.renderMarkdown()
|
|
29
|
+
const markdownContent = markdownResult.content
|
|
30
|
+
const componentName = path.basename(fileWithPath, '.vue')
|
|
31
|
+
|
|
32
|
+
if (!fs.existsSync(outputDir)) {
|
|
33
|
+
fs.mkdirSync(outputDir)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
fs.writeFile(`${outputDir}/${componentName}.md`, markdownContent, (err) => {
|
|
37
|
+
if (err) {
|
|
38
|
+
console.error(`Error writing markdown file for ${componentName}`, err)
|
|
39
|
+
} else {
|
|
40
|
+
console.log(`Markdown file for ${componentName} is generated!`)
|
|
41
|
+
}
|
|
42
|
+
})
|
|
43
|
+
} catch(e) {
|
|
44
|
+
console.error(e)
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// To generate markdown files - one time
|
|
49
|
+
components.forEach((component) => {
|
|
50
|
+
console.log(`Write markdown file for ${component} on first load.`)
|
|
51
|
+
generateMarkdown(component)
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
// To watch component changes and generate markdown files
|
|
55
|
+
if (watchMode) {
|
|
56
|
+
const watcher = chokidar.watch(components, {
|
|
57
|
+
cwd: componentsDir,
|
|
58
|
+
ignoreInitial: true,
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
watcher.on('change', (file) => {
|
|
62
|
+
console.log(`The component ${file} has changed!`)
|
|
63
|
+
generateMarkdown(file)
|
|
64
|
+
})
|
|
65
|
+
}
|
package/styleguide.config.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
// set your styleguidist configuration here
|
|
3
|
-
title: 'Scaffoldvuer API reference',
|
|
4
|
-
components: 'src/components/ScaffoldVuer.vue',
|
|
5
|
-
// defaultExample: true,
|
|
6
|
-
// sections: [
|
|
7
|
-
// {
|
|
8
|
-
// name: 'First Section',
|
|
9
|
-
// components: 'src/components/**/[A-Z]*.vue'
|
|
10
|
-
// }
|
|
11
|
-
// ],
|
|
12
|
-
// webpackConfig: {
|
|
13
|
-
// // custom config goes here
|
|
14
|
-
// },
|
|
15
|
-
exampleMode: 'expand',
|
|
16
|
-
copyCodeButton: true,
|
|
17
|
-
ribbon: {
|
|
18
|
-
url: 'https://github.com/ABI-Software/scaffoldvuer',
|
|
19
|
-
text: 'Github Page'
|
|
20
|
-
},
|
|
21
|
-
styleguideDir: 'docs'
|
|
22
|
-
}
|