68 Commits

Author SHA1 Message Date
Samuele Locatelli c34644be96 Merge branch 'release/FixUpdateNodeVers21' 2026-01-27 16:16:49 +01:00
Samuele Locatelli 20c9e4d058 update modifiche su src x compilazione npm 2026-01-27 16:16:18 +01:00
Samuele Locatelli 0e9f675048 Aggiunto script x riportare modifiche su SRC 2026-01-27 15:48:02 +01:00
Riccardo Elitropi 40a7df5520 Aggiornamento ambiente test live 2026-01-27 14:48:17 +01:00
Samuele Locatelli d1bab45745 Inizio setup ambiente test live modulo con vite (vs vue) 2026-01-27 11:28:01 +01:00
Samuele Locatelli 0a93746352 modifica yaml ci/cd x cercare folder src vs WebGl x icarus viewer 2026-01-27 09:27:53 +01:00
Samuele Locatelli 7a8e85b95d webDoorView: ripristino situazione a ultima modifica (da rivedere x proj cs) 2026-01-27 09:26:33 +01:00
Samuele Locatelli 310f923319 Icarus view:
- spostamento da WebGl a src degli script sorgente x coerenza modello sviluppo
2026-01-27 09:25:57 +01:00
Samuele Locatelli 6eec667964 Merge tag 'AddNpmWebDoorViewer_02' into develop
Update src + update readme x uso componente
2024-06-26 16:55:30 +02:00
Samuele Locatelli 3497c70fb9 Merge branch 'release/AddNpmWebDoorViewer_02' 2024-06-26 16:54:26 +02:00
Samuele Locatelli 94d93223ea Fix CI/CD x main deploy package
- update readme c#
update src x compilazione
2024-06-26 16:54:00 +02:00
Samuele Locatelli 218625fba4 Merge tag 'AddNpmWebDoorViewer_01' into develop
Aggiunta primo rilascio webdoor viewer
2024-06-26 16:23:50 +02:00
Samuele Locatelli a9de0e61df Merge branch 'release/AddNpmWebDoorViewer_01' 2024-06-26 16:05:35 +02:00
Samuele Locatelli 2886402d55 typo commenti 2024-06-26 16:05:16 +02:00
Samuele Locatelli 07fcc47685 Update area TJSD + yaml x robocopy 2024-06-26 15:51:08 +02:00
Samuele Locatelli 27881a1acc update yaml CI/CD 2024-06-26 15:46:26 +02:00
Samuele Locatelli e4502353af Refresh index x compilare npm 2024-06-26 15:42:22 +02:00
Samuele Locatelli ebdb36180e Completato review classi in test!!! ok tablet 2024-06-26 15:21:48 +02:00
Samuele Locatelli 9b902473c2 Update grafico pagina visualizzatore 2024-06-26 10:55:51 +02:00
Samuele Locatelli 3a0161a3dd Update pagina base x nuovi buttons 2024-06-25 18:37:45 +02:00
Samuele Locatelli c054880749 Update comportamento rotazioni e start/stop animazione 2024-06-25 17:32:57 +02:00
Samuele Locatelli 845e309769 Update gestione controlli 2024-06-25 17:10:00 +02:00
Samuele Locatelli 3ba52f1aee fix click sul cubo 2024-06-25 12:33:29 +02:00
Samuele Locatelli 8de856ba4c update gestione start/stop animazione 2024-06-25 12:32:00 +02:00
Samuele Locatelli 4860c824af Fix comportamento animazione start/stop x risparmio GPU 2024-06-25 12:10:27 +02:00
Samuele Locatelli 67ac56922f Fix commenti e continuo reorg codice 2024-06-25 11:08:50 +02:00
Samuele Locatelli 1c949d0329 Spostata gestione eventi in pagina 2024-06-25 10:55:57 +02:00
Samuele Locatelli ae30af04ca yaml da testare... 2024-06-22 12:48:37 +02:00
Samuele Locatelli 1a73e06fc4 Update yaml x CI/CD (proviamo nuovo pacchetto...) 2024-06-22 12:15:18 +02:00
Samuele Locatelli 1581e03d3e Update area src x npm 2024-06-22 12:15:02 +02:00
Samuele Locatelli b26ba3824f review test area con 2 varianti index2 e index3 2024-06-22 10:48:51 +02:00
Samuele Locatelli 6fa3363acc update parziale draw.js 2024-06-21 17:12:04 +02:00
Samuele Locatelli bac6276c3d Fix test js only ridotto ai minimi termini, inizio gestione bootstrapper 2024-06-21 16:47:04 +02:00
Samuele Locatelli 4dcc7a0117 Aggiunta progetto test solo x 3mf e doors in c# 2024-06-21 16:29:31 +02:00
Samuele Locatelli b9819261b0 pulizia progetto test vecchio 3mf slicer 2024-06-21 15:31:42 +02:00
Samuele Locatelli cb0bf3aa38 Pulizia area webDoorView x creare npm 2024-06-21 15:03:09 +02:00
Samuele Locatelli 5ae9229f60 Riorganizzato area test IIS con minimo indispensabile 2024-06-21 15:02:49 +02:00
Samuele Locatelli df397c7a06 refresh (non va ) 2024-06-20 19:59:55 +02:00
Samuele Locatelli 5f3497259d Ancora spostamenti libs (da rivedere...) 2024-06-20 19:59:50 +02:00
Samuele Locatelli db13a4b89a reorg file 2024-06-20 19:46:20 +02:00
Samuele Locatelli 38b4cb70c3 Aggiunta demo page x door 2024-06-20 19:46:12 +02:00
Samuele Locatelli c2fa7debf5 Add js x test plot door 2024-06-20 19:31:59 +02:00
Samuele Locatelli 68c781f047 Modifica nome pagine 2024-06-20 19:31:46 +02:00
Samuele Locatelli bce4a9ac7f Aggiunta preliminare libreria webgl (da ripulire?!?) 2024-06-20 19:31:35 +02:00
Samuele Locatelli ad95f94e1f Fix progetto CSharp x demo 3d slicer 2024-06-20 19:11:36 +02:00
Samuele Locatelli 9d21649e42 Aggiunta npmrc da usare x auth 2024-06-11 15:38:58 +02:00
Samuele Locatelli 4678ca1424 Fix pagina index 2024-06-11 11:46:00 +02:00
Riccardo Elitropi 0edea24c43 Primo codice di prova ( testare funzionalità ). 2024-03-27 13:08:46 +01:00
Riccardo Elitropi 8d1cbef568 primo commit ( versione di prova ). 2024-03-26 13:20:40 +01:00
Samuele Locatelli f749cb75b9 rimessa cartella build di threejs 2024-03-26 08:35:48 +01:00
Samuele Locatelli baf418e11b Fix deploy IIS01 + recupero versione IIS01 attuale 2024-03-26 08:11:56 +01:00
Samuele Locatelli 450994be2e correzione path X 2024-03-26 08:06:55 +01:00
Samuele Locatelli 462cea065c Correzione dest path 2024-03-25 20:17:13 +01:00
Samuele Locatelli bc341f4f81 aggiunto output cmd net use 2024-03-25 20:13:05 +01:00
Samuele Locatelli fee5c27494 Modifica gitlab x copia rsync verso IIS01... 2024-03-25 20:08:55 +01:00
Samuele Locatelli 5e971e6cfd Readme x area webdoor (da completare) 2024-03-25 09:00:36 +01:00
Samuele Locatelli 93c5a8a37a Aggiunto area test IIS01 2024-03-25 08:55:25 +01:00
Samuele Locatelli 438399d7a1 Riorganizzazione REPO x multi viewers 2024-03-25 08:51:52 +01:00
Samuele Locatelli 2fcd7490ec Merge remote-tracking branch 'origin/main' into develop 2024-03-25 08:17:11 +01:00
zaccaria.majid 60cdd29467 fix ancora pacchetto rhino 2023-10-27 16:54:55 +02:00
zaccaria.majid 88de130f3f fix call inutile a rhino 2023-10-27 16:50:43 +02:00
zaccaria.majid f4de5a3334 Merge branch 'develop' 2023-10-27 16:36:47 +02:00
zaccaria.majid 99f2ebf7d4 aggiunti parametri approx e isOrto 2023-10-25 16:27:05 +02:00
zaccaria.majid d17149f05e fix call con nome sbagliato 2023-10-24 10:40:34 +02:00
zaccaria.majid ec48782dc8 Merge branch 'develop' 2023-10-24 10:34:09 +02:00
zaccaria.majid ec5892849a Merge branch 'develop' 2023-10-05 09:53:21 +02:00
zaccaria.majid 8fe2f1571e Merge branch 'develop' 2023-10-04 08:44:20 +02:00
zaccaria.majid f300e37ef3 commentati momentaneamente loaders 2023-10-03 16:11:25 +02:00
1834 changed files with 701009 additions and 772 deletions
+3 -17
View File
@@ -2,32 +2,17 @@
#############################################
# Area generale
#############################################
StockMan.suo
*.suo
*.bak
*.cache
*.pdb
.DS_Store
#ignoro i pdb: area comune packages
/packages/AjaxControlToolkit.4.1.60623/lib/40/*.pdb
/packages/AjaxControlToolkit.4.1.60623/lib/35/*.pdb
/packages/*.pdb
/packages/*/*.pdb
/packages/*/*/*.pdb
/packages/*
#############################################
# Area SHERPA
#############################################
# ignoro i files log/PDF/temp
SHERPA/logs/*.txt
SHERPA/logs/*.zip
|SHERPA/logs/.PlaceHolder.file
SHERPA/bin/*
SHERPA/obj/*
VersGen/bin/*
VersGen/obj/*
@@ -0,0 +1,333 @@
# ---> VisualStudio
@@ -50,7 +35,8 @@ VersGen/obj/*
[Rr]eleases/
x64/
x86/
build/
#2024.03.26 rimessa area build x costruzione base path di threejs
#build/
bld/
[Bb]in/
[Oo]bj/
@@ -97,7 +83,7 @@ artifacts/
*.log
*.vspscc
*.vssscc
.builds
#.builds
*.pidb
*.svclog
*.scc
+82 -15
View File
@@ -8,8 +8,13 @@ variables:
NEW_COPYRIGHT: 'EgalWare 2022+'
JSON_FILE: ''
JSON_FILE_RAW: ''
NET_SHARE_X: '\\iis01\Test3D'
NET_USERQ: 'steamw\egalware'
SRC_PATH: 'TestArea_IIS01\'
# valutare se elenco --> ciclo https://docs.gitlab.com/ee/ci/variables/#store-multiple-values-in-one-variable
DIR_PATH: 'TJSD THREEJS_DOORS'
# helper (anchors, vedere https://docs.gitlab.com/ee/ci/yaml/yaml_optimization.html) x fix vers number
.version-fix: &version-fix
- |
$env:NEW_REL = $env:VERS_MAIN+"."+(get-date -format yyMM) + (get-date -format ddHH)
@@ -22,6 +27,21 @@ variables:
Write-Output $resoconto;
echo "VersionFix done"
# helper copia area test 3D verso cartella di rete X:\ (IIS01) delle cartelle della TestArea_IIS01
.ReplicaX: &ReplicaX
- |
net use X: /delete
SLEEP 2
#$mountCmd = "net use X: $env:NET_SHARE_X /u:$env:NET_USERQ $SDRIVE_PASSWD"
#Write-Output $mountCmd;
net use X: $env:NET_SHARE_X /u:$env:NET_USERQ $SDRIVE_PASSWD
Foreach ($sDir in ($env:DIR_PATH -split " ")) {
#Write-Output "ROBOCOPY /MIR $env:SRC_PATH\$sDir\ X:\$sDir\"
ROBOCOPY /MIR $env:SRC_PATH\$sDir\ X:\$sDir\
}
SLEEP 2
net use X: /delete
image:
node:latest
@@ -30,17 +50,19 @@ stages:
- release
# ---------- Upload Debug/Unstable ----------
WebGl3D:deploy:
before_script:
- *version-fix
tags:
- win
WebGl.Icarus:deploy:
stage: build
variables:
APP_NAME: WebGl-Visualizer
only:
- develop
stage: build
tags:
- win
before_script:
- *version-fix
- *ReplicaX
script:
- cd .\WebGl\
- cd .\IcarusView\src\
- Set-Content -Path "./.npmrc" -Value "email=ceo@steamware.net `nalways-auth=true `n//nexus.steamware.net/repository/npm-hosted/:_authToken=$NPM_TOKEN"
- $JSON_FILE = Get-Content '.\package.json' -raw
- $JSON_FILE_RAW = $JSON_FILE | ConvertFrom-Json
@@ -49,17 +71,62 @@ WebGl3D:deploy:
- echo "//nexus.steamware.net/repository/npm-hosted/:_authToken=$NPM_TOKEN"
- npm publish
# ---------- RELEASE ----------
WebGl3D:release:
before_script:
- *version-fix
WebGl.Door:deploy:
stage: build
variables:
APP_NAME: WebGl-Door-Visualizer
only:
- develop
tags:
- win
before_script:
- *version-fix
- *ReplicaX
script:
- cd .\WebDoorView\src\
- Set-Content -Path "./.npmrc" -Value "email=ceo@steamware.net `nalways-auth=true `n//nexus.steamware.net/repository/npm-hosted/:_authToken=$NPM_TOKEN"
- $JSON_FILE = Get-Content '.\package.json' -raw
- $JSON_FILE_RAW = $JSON_FILE | ConvertFrom-Json
- $JSON_FILE_RAW.version="$env:NUM_DEB"
- $JSON_FILE_RAW | ConvertTo-Json -depth 32| set-content '.\package.json'
- echo "//nexus.steamware.net/repository/npm-hosted/:_authToken=$NPM_TOKEN"
- npm publish
# ---------- RELEASE ----------
WebGl3D.Icarus:release:
stage: release
variables:
APP_NAME: WebGl-Visualizer
only:
- main
stage: release
tags:
- win
before_script:
- *version-fix
- *ReplicaX
script:
- cd .\WebGl\
- cd .\IcarusView\src\
- Set-Content -Path "./.npmrc" -Value "email=ceo@steamware.net `nalways-auth=true `n//nexus.steamware.net/repository/npm-hosted/:_authToken=$NPM_TOKEN"
- $JSON_FILE = Get-Content '.\package.json' -raw
- $JSON_FILE_RAW = $JSON_FILE | ConvertFrom-Json
- $JSON_FILE_RAW.version="$env:NEW_REL"
- $JSON_FILE_RAW | ConvertTo-Json -depth 32| set-content '.\package.json'
- echo "//nexus.steamware.net/repository/npm-hosted/:_authToken=$NPM_TOKEN"
- npm publish
WebGl3D.Door:release:
stage: release
variables:
APP_NAME: WebGl-Door-Visualizer
only:
- main
tags:
- win
before_script:
- *version-fix
- *ReplicaX
script:
- cd .\WebDoorView\src\
- Set-Content -Path "./.npmrc" -Value "email=ceo@steamware.net `nalways-auth=true `n//nexus.steamware.net/repository/npm-hosted/:_authToken=$NPM_TOKEN"
- $JSON_FILE = Get-Content '.\package.json' -raw
- $JSON_FILE_RAW = $JSON_FILE | ConvertFrom-Json
-3
View File
@@ -1,3 +0,0 @@
email=ceo@steamware.net
always-auth=true
//nexus.steamware.net/repository/npm-hosted/:_authToken=NpmToken.9adde2db-ccdc-3a28-bd41-ff4f3d711993
-17
View File
@@ -1,17 +0,0 @@
{
"version": "1.0",
"defaultProvider": "filesystem",
"libraries": [
{
"library": "C:\\Users\\zaccaria.majid\\Downloads\\package",
"destination": "wwwroot/lib/package/"
},
{
"library": "C:\\Users\\zaccaria.majid\\Downloads\\",
"destination": "wwwroot/lib/Downloads/",
"files": [
"webgl-visualizer-1.1.230926-beta.842.tgz"
]
}
]
}
+4
View File
@@ -0,0 +1,4 @@
email=ceo@steamware.net
always-auth=true
//nexus.steamware.net/repository/npm-hosted/:_authToken=NpmToken.9adde2db-ccdc-3a28-bd41-ff4f3d711993
//nexus.steamware.net/repository/npm-group/:_authToken=NpmToken.63c81032-4adf-327f-b9b0-9ab32f867706
@@ -21,11 +21,12 @@
let options ={
_dimX : X,
_dimY: Y,
_fileName: "Ex3.3dm",
_fileName: "ProjectSlice.3dm",
_showGrid: true,
_showInfiniteGrid: false,
_isOrtographic: true,
_sourceDir: "./src/source/",
_modelsDir: "./src/source/models/",
_fileType: '3DM',
_showFrame: true,
_frameType: 2,
@@ -34,7 +35,7 @@
_approxIndex: 5,
}
console.log(options._souceDir + options._fileName)
console.log(options._sourceDir + options._fileName)
WGL.initcall(options);
document.getElementById("refre_slider").oninput = function() {
@@ -10,7 +10,7 @@
"license": "MIT",
"dependencies": {
"vue": "^2.5.11",
"webgl-visualizer": "^1.2.231023-beta.1106"
"webgl-visualizer": "^1.2.23102410"
},
"devDependencies": {
"babel-core": "^6.26.0",
@@ -9296,9 +9296,9 @@
}
},
"node_modules/webgl-visualizer": {
"version": "1.2.231023-beta.1106",
"resolved": "https://nexus.steamware.net/repository/npm-group/webgl-visualizer/-/webgl-visualizer-1.2.231023-beta.1106.tgz",
"integrity": "sha512-sEA/GbeshPuIKnDDDfZGdS91QhnJsy8Vi/k/az57J2Wv9Ahx7DMhjF5S7EhI33JxQ0ZXJQYCSaoBe3eTOwgZ3A==",
"version": "1.2.23102410",
"resolved": "https://nexus.steamware.net/repository/npm-group/webgl-visualizer/-/webgl-visualizer-1.2.23102410.tgz",
"integrity": "sha512-TAM6j63UVjTVMkOjBR1je0TGEEVJCeDOzze2macpHHjRgf4A1ngcWmElH5UYn0TQz9+8otmvTYUcTHKDN5501A==",
"license": "ISC"
},
"node_modules/webpack": {
@@ -11,7 +11,7 @@
},
"dependencies": {
"vue": "^2.5.11",
"webgl-visualizer": "^1.2.231023-beta.1106"
"webgl-visualizer": "^1.2.23102410"
},
"browserslist": [
"> 1%",
@@ -15,7 +15,9 @@
<input type='button' id='bt_camera' value = "Toggle Camera">
<input type='checkbox' id='ck_print' checked>
</div>
<div id = "WebGL-Export">
<div id="test-id">
<div id = "WebGL-Export">
</div>
</div>
</div>
</template>

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 6.7 KiB

@@ -0,0 +1,6 @@
{
"presets": [
["env", { "modules": false }],
"stage-3"
]
}
@@ -0,0 +1,9 @@
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
@@ -0,0 +1,12 @@
.DS_Store
node_modules/
dist/
npm-debug.log
yarn-error.log
# Editor directories and files
.idea
*.suo
*.ntvs*
*.njsproj
*.sln
@@ -0,0 +1,18 @@
# web3d_viewer
> A Vue.js project
## Build Setup
``` bash
# install dependencies
npm install
# serve with hot reload at localhost:8080
npm run dev
# build for production with minification
npm run build
```
For detailed explanation on how things work, consult the [docs for vue-loader](http://vuejs.github.io/vue-loader).
@@ -0,0 +1,82 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>web3d_viewer</title>
</head>
<body>
<div id="app"></div>
<script src="/dist/build.js"></script>
</body>
<script type="module">
import { webgl_original } from './src/draw/webgl_drawVue.js';
const WGL = new webgl_original();
// var options = new Object();
var X = 960;
var Y = 540;
let options ={
_dimX : X,
_dimY: Y,
_fileName: "ProjectSlice.3dm",
_showGrid: true,
_showInfiniteGrid: false,
_isOrtographic: true,
_sourceDir: "./src/source/",
_modelsDir: "./src/source/models/",
_fileType: '3DM',
_showFrame: true,
_frameType: 2,
_frameLen: 150, //mm
_frameFat: 4, //mm
_approxIndex: 5,
}
console.log(options._sourceDir + options._fileName)
WGL.initcall(options);
document.getElementById("refre_slider").oninput = function() {
myFunction()
};
function myFunction() {
var val = document.getElementById("refre_slider").value //gets the oninput value
console.log(val)
WGL.refreshcall(1, val)
}
document.getElementById('btnRef').onclick = function() {
options._dimX= document.getElementById('dimX').value;
options._dimY = document.getElementById('dimY').value;
console.log(X);
console.log(Y);
console.log(options);
// const container = document.getElementById('WebGL-3mfExport');
// const child = document.getElementsByTagName('canvas');
// container.removeChild(child);
const element = document.getElementsByTagName("canvas");
element[0].remove();
WGL.initcall(options);
}
document.getElementById('btnResetCam').onclick = function() {
WGL.resetCamera();
}
document.getElementById('bt_camera').onclick = function() {
WGL.setCameraType();
}
document.getElementById('ck_print').onclick = function(){
var val = document.getElementById('ck_print').checked;
WGL.showPrintDirection(val);
}
</script>
<script src="src/draw/webgl_drawVue.js" type="module"></script>
</html>
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,34 @@
{
"name": "web3d_viewer",
"description": "A Vue.js project",
"version": "1.0.0",
"author": "zaccaria.majid <zaccaria.majid@egalware.com>",
"license": "MIT",
"private": true,
"scripts": {
"dev": "cross-env NODE_ENV=development webpack-dev-server --open --hot",
"build": "cross-env NODE_ENV=production webpack --progress --hide-modules"
},
"dependencies": {
"vue": "^2.5.11",
"webgl-visualizer": "^1.2.23102410"
},
"browserslist": [
"> 1%",
"last 2 versions",
"not ie <= 8"
],
"devDependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-preset-env": "^1.6.0",
"babel-preset-stage-3": "^6.24.1",
"cross-env": "^5.2.1",
"css-loader": "^0.28.7",
"file-loader": "^1.1.4",
"vue-loader": "^13.0.5",
"vue-template-compiler": "^2.4.4",
"webpack": "^3.6.0",
"webpack-dev-server": "^2.9.1"
}
}
@@ -0,0 +1,63 @@
<template>
<div id="app">
<div style="display: flex; justify-content: center; flex: wrap; align-items: center; margin-bottom: 10px; ">
<img src="src/assets/LogoClassic_NoText.png" style="width: 175px; height: 175px;"/>
<h1 style="margin: 20px;">
EGW Web3D Viewer
</h1>
</div>
<div>
<input type="number" id="dimX" placeholder="dimX" value="960" />
<input type="number" id="dimY" placeholder="dimY" value="540" />
<input type="range" id="refre_slider" max="1000" />
<button id="btnRef">Resize</button>
<button id="btnResetCam">Reset camera</button>
<input type='button' id='bt_camera' value = "Toggle Camera">
<input type='checkbox' id='ck_print' checked>
</div>
<div id="test-id">
<div id = "WebGL-Export">
</div>
</div>
</div>
</template>
<script>
export default {
name: 'app',
data () {
return {
msg: 'Welcome to Your Vue.js App'
}
}
}
</script>
<style>
#app {
font-family: 'Avenir', Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
h1, h2 {
font-weight: normal;
}
ul {
list-style-type: none;
padding: 0;
}
li {
display: inline-block;
margin: 0 10px;
}
a {
color: #42b983;
}
</style>
Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

@@ -0,0 +1,831 @@
import * as THREE from '../threeJsLib/three.module.js';
import { OrbitControls } from '../jsm/controls/OrbitControls.js';
import { ThreeMFLoader } from '../jsm/loaders/3MFLoader.js';
import { Rhino3dmLoader } from '../jsm/loaders/3DMLoader.js';
// import { Rhino3dmLoader } from '../../webgl-visualizer/draw/';
//import * as RHINO from '../jsm/rhino3dm.js';
// VARIABILI DI CONTROLLO
// *** div dimensions ***
var m_divStartDimX = 500;
var m_divStartDimY = 400;
var fName = "";
//var fileType = "3MF";
var fileType = '3DM';
var m_nApproxIndex = 0;
var m_bShowDir = true;
// *** camera settings ***
var m_bZoom = true;
var m_bPan = true;
var m_bRot = true;
var m_nCameraStartPos = 8 ;
var m_bIsOrtographic = true ;
// *** index blender ***
var m_nStartL = 0;
var m_nEndL = 1000000;
// *** frame settings ***
var m_bShowFrame = true ;
var m_lFrameLen = 100 ;
var m_dFrameFat = 2; // raggio del cilindro
var m_bFrameType = 2 ;
var m_bAutoRot = false;
// *** grid settings ***
var m_bShowGrid = true ;
var m_bInfGrid = true ;
// *** Direction Arrows ***
var m_bShowPrintDir = true ;
var sourceDir = '' ;
//var useInSlider = false;
var counter = 0;
var nStartLayer = -100000 ;
var ORIG = new THREE.Vector3( 0, 0, 0), vtExtr = new THREE.Vector3( 0, 1, 0), dStrand ;
let activeCamera, scene, renderer, controls, perspectiveCamera, orthographicCamera;
var layer_list = [];
const GLBox3D = new THREE.Box3(); // Box3D globale delle geometrie
//init();
class webgl_original {
async initcall({ _dimX, _dimY, _fileName, _isOrtographic , _showInfiniteGrid, _fileType, _sourceDir, _showGrid, _showFrame, _frameType, _frameLen, _frameFat, _approxIndex}) {
m_divStartDimX = _dimX;
m_divStartDimY = _dimY;
m_bShowGrid = _showGrid;
fName = _fileName;
m_bIsOrtographic = _isOrtographic;
m_bInfGrid = _showInfiniteGrid;
sourceDir = _sourceDir;
fileType = _fileType;
m_bShowFrame = _showFrame;
m_bFrameType = _frameType;
m_lFrameLen = _frameLen;
m_dFrameFat = _frameFat;
m_nApproxIndex = _approxIndex;
//console.log(fName)
setLoaders();
if(fileType.toUpperCase() == '3MF')
{
await init3mf();
}
else if(fileType.toUpperCase() == '3DM')
{
await init3dm();
}
else
{
console.log('File type not supported')
}
}
setCameraType(){
toggleCamera( perspectiveCamera, orthographicCamera);
}
refreshcall(nStart, nEnd) {
refreshElement(nStart, nEnd);
}
resetCamera() {
SetCameraPos( m_nCameraStartPos, ORIG) ;
}
showPrintDirection(showDir) {
ShowPrintDir(showDir) ;
}
}
export { webgl_original }
function setLoaders() {
//<input type="range" class="form-range" id="customRange1">
let mother = document.getElementById('WebGL-Export');
if(fileType.toUpperCase() == '3DM')
{
mother = document.getElementById('WebGL-Export')
}
const spinContainer = document.createElement('div');
const elParent = document.createElement('div');
const elChild1 = document.createElement('div');
const elChild2 = document.createElement('div');
const elChild3 = document.createElement('div');
const elChild4 = document.createElement('div');
const elChild5 = document.createElement('div');
const elChild6 = document.createElement('div');
const loadTxt = document.createElement('div');
mother.appendChild(spinContainer);
//document.body.appendChild(spinContainer);
spinContainer.appendChild(elParent);
spinContainer.appendChild(loadTxt);
elParent.appendChild(elChild1);
elParent.appendChild(elChild2);
elParent.appendChild(elChild3);
elParent.appendChild(elChild4);
elParent.appendChild(elChild5);
elParent.appendChild(elChild6);
loadTxt.setAttribute('id', 'loadTxt');
spinContainer.setAttribute('id', 'spinContainer');
var st = 'height: ' + m_divStartDimY + 'px ; width: ' + m_divStartDimX + 'px ; background-color: #a0a0a0';
spinContainer.setAttribute("style", st);
elParent.setAttribute('id', 'sp');
elParent.classList.add('spinner');
loadTxt.style.padding = '30px 0 0 0'
loadTxt.innerText = 'Loading...';
loadTxt.style.fontSize = '50px';
loadTxt.style.fontFamily = 'Helvetica';
spinContainer.style.display = 'flex';
spinContainer.style.alignItems = 'center';
spinContainer.style.justifyContent = 'center';
spinContainer.style.flexDirection = 'column';
elParent.style.width = '70.4px';
elParent.style.height = '70.4px';
elParent.style.setProperty('--clr', 'rgb(247, 197, 159)');
elParent.style.setProperty('--clr-alpha', 'rgb(247, 197, 159,.1)');
elParent.style.transformStyle = 'preserve-3d';
elParent.animate([
// key frames
{ transform: 'rotate(45deg) rotateX(-25deg) rotateY(25deg)' },
{ transform: 'rotate(45deg) rotateX(-385deg) rotateY(25deg)' },
{ transform: 'rotate(45deg) rotateX(-385deg) rotateY(385deg)' }
], {
// sync options
duration: 2600,
iterations: Infinity,
easing: 'ease',
rangeStart: "cover 0%",
rangeEnd: "cover 100%"
});
var cDiv = elParent.children;
for (var i = 0; i < cDiv.length; i++) {
if (cDiv[i].tagName == "DIV") { //or use toUpperCase()
cDiv[i].style.height = '100%';
cDiv[i].style.position = 'absolute';
cDiv[i].style.width = '100%';
cDiv[i].style.border = '#afc5d6';
cDiv[i].style.backgroundSize = 'contain';
// cDiv[i].style.backgroundColor = '#000';
cDiv[i].style.backgroundImage = 'url(../node_modules/webgl-visualizer/styles/LogoClassic_NoText.png)'
}
}
elChild1.style.transform = 'translateZ(-35.2px) rotateY(180deg)';
elChild2.style.transform = 'rotateY(-270deg) translateX(50%)';
elChild2.style.transformOrigin = 'top right';
elChild3.style.transform = 'rotateY(270deg) translateX(-50%)';
elChild3.style.transformOrigin = 'center left';
elChild4.style.transform = 'rotateX(90deg) translateY(-50%)';
elChild4.style.transformOrigin = 'top center';
elChild5.style.transform = 'rotateX(-90deg) translateY(50%)';
elChild5.style.transformOrigin = 'bottom center';
elChild6.style.transform = 'translateZ(35.2px)';
}
function init3mf() {
const manager = new THREE.LoadingManager() ;
const loader = new ThreeMFLoader( manager) ;
let startTime = performance.now();
return new Promise(() => {
setTimeout(() => {
loader.load( sourceDir + 'models/' + fName, function ( object) {
object.rotation.set( -Math.PI / 2, 0, 0) ;
console.log( object) ;
for ( var i = 0 ; i < object.children.length ; ++ i) {
var child = object.children[i] ;
child.rotation.set( -Math.PI/2, 0 ,0) ;
layer_list.push( child) ;
}
// Adapting Scene to contest
AdaptSeceneToContest() ;
let endTime = performance.now();
let timeElapsed = endTime - startTime;
console.log('init3mf in : ' + timeElapsed)
console.log( new Date()) ;
}) ;
}, 0);
});
}
function init3dm(){
const loader = new Rhino3dmLoader() ;
let startTime = performance.now();
console.log( new Date()) ;
return new Promise(() => {
setTimeout(() => {
loader.setLibraryPath( sourceDir + 'rhino/' ) ;
loader.load( sourceDir + 'models/' + fName, m_nApproxIndex, function ( object ) {
object.traverse( function( child) {
child.castShadow = true ;
}) ;
// Ref systems
const Mat_GlobToLoc = new THREE.Matrix4() ; //<---- rotations for XY plane from Extrusion
const Mat_LocToGlob = new THREE.Matrix4() ; //<---- rotations for Extrusion from XY plane
const Mat_ThreeJs_Frame = new THREE.Matrix4() ; // <----- rotations from XYZ ref system to ThreeJS system
Mat_ThreeJs_Frame.set( 1, 0, 0, 0,
0, 0, 1, 0,
0, -1, 0, 0,
0, 0, 0, 1) ;
var Mat_ToScene = new THREE.Matrix4() ;
// Extrusion settings for curves
const extrudeSettings = {
steps: 1,
depth: 0,
bevelEnabled: false,
bevelThickness: 1,
bevelSize: 1,
bevelOffset: 0,
bevelSegments: 1
} ;
// loading entities...
for ( var i = 0 ; i < object.children.length ; ++ i) {
// getting i-th object
var child = object.children[i] ;
//console.log( child);
// READING A POINT TYPE -----------------------------------------------------------------
if ( child.type == 'Points') {
try {
if ( child.name != 'Orig') {
console.log( 'Not a valid origin') ;
return false ;
}
// start layer
nStartLayer = parseInt( child.userData.attributes.layerIndex) ;
// ORIGIN ------------------------
var coord = child.userData.attributes.geometry.location ;
var orig_x = parseFloat( coord[0]) ;
var orig_y = parseFloat( coord[2]) ;
var orig_z = - parseFloat( coord[1]) ;
ORIG = new THREE.Vector3( orig_x, orig_y, orig_z) ;
// EXTRUSION ---------------------
var bOk_ext = false ;
if ( child.userData.attributes.userStrings[1][0] == 'SlicingDir') {
var sExtr = child.userData.attributes.userStrings[1][1] ;
if ( sExtr != "" ) {
let sExtr_arr = sExtr.split(',') ;
if ( sExtr_arr.length == 3) {
var dExtr_x = parseFloat( sExtr_arr[0]) ;
var dExtr_y = parseFloat( sExtr_arr[1]) ;
var dExtr_z = parseFloat( sExtr_arr[2]) ;
vtExtr = new THREE.Vector3( dExtr_x, dExtr_y, dExtr_z) ;
bOk_ext = true ;
}
}
}
if ( ! bOk_ext) {
console.log( ' Not a valid Extrusion') ;
return false ;
}
var Z_AX = new THREE.Vector3( vtExtr.x, vtExtr.y, vtExtr.z) ;
var X_AX = new THREE.Vector3() ;
var Y_AX = new THREE.Vector3() ;
if ( ! Z_AX.equals( new THREE.Vector3( 0, 0, 1))) {
X_AX.crossVectors( new THREE.Vector3( 0, 0, 1), Z_AX) ;
Y_AX.crossVectors( Z_AX, X_AX) ;
}
else {
X_AX = new THREE.Vector3( 1, 0, 0) ;
Y_AX = new THREE.Vector3( 0, 1, 0) ;
}
Mat_GlobToLoc.set( X_AX.x, X_AX.y, X_AX.z, 0,
Y_AX.x, Y_AX.y, Y_AX.z, 0,
Z_AX.x, Z_AX.y, Z_AX.z, 0,
0, 0, 0, 1) ;
Mat_LocToGlob.copy( Mat_GlobToLoc) ;
Mat_LocToGlob.invert() ;
Mat_ToScene.multiplyMatrices( Mat_ThreeJs_Frame, Mat_LocToGlob) ;
// STRAND -------------------------
if ( child.userData.attributes.userStrings[0][0] == 'StrandH') {
dStrand = - parseFloat( child.userData.attributes.userStrings[0][1]) ;
extrudeSettings.depth = dStrand ;
}
else {
console.log( ' Not a valid Strand') ;
return false ;
}
}
catch( error) {
console.log( 'Orig, Extrusion or Strand missing or not implemented') ;
return false ;
}
}
// READING A LINE -----------------------------------------------------------------------
else if ( child.type == 'Line') {
// Parsing the extrusion and the Layer of the curve
try {
var nLayer = parseInt( child.userData.attributes.layerIndex) - nStartLayer ;
if ( nLayer < 0)
return false ;
var points_array = child.geometry.attributes.position.array ;
//var ptPrec ;
const shape = new THREE.Shape() ;
for ( var v = 0 ; v < points_array.length ; v += 3) {
var Zact ;
var vtCoord = new THREE.Vector4( points_array[v], points_array[v+1], points_array[v+2], 1) ;
vtCoord.applyMatrix4( Mat_GlobToLoc) ;
//if ( v != 0 && v < points_array.length - 3 &&
// (( vtCoord.x - ptPrec.x) * ( vtCoord.x - ptPrec.x) +
// ( vtCoord.y - ptPrec.y) * ( vtCoord.y - ptPrec.y) +
// ( vtCoord.z - ptPrec.z) * ( vtCoord.z - ptPrec.z)) < 10)
// continue ;
if ( v == 0) {
shape.moveTo( vtCoord.x, vtCoord.y) ;
Zact = vtCoord.z ;
}
else
shape.lineTo( vtCoord.x, vtCoord.y) ;
//ptPrec = new THREE.Vector4( vtCoord.x, vtCoord.y, vtCoord.z, 1) ;
}
var cCol = child.material.color.clone() ;
if ( nLayer%2 == 0) {
cCol.lerp( new THREE.Color( 0x000000 ), 0.25) ;
}
const geometry = new THREE.ExtrudeGeometry( shape, extrudeSettings) ;
//const material = new THREE.MeshLambertMaterial({ color: cCol, wireframe : false, shadowSide : THREE.DoubleSide}) ;
const material = new THREE.MeshStandardMaterial({ color: cCol,
wireframe : false,
shadowSide : THREE.DoubleSide,
metalness : 0.8,
name: "__DEFAULT",
shadowSide: null,
side: 2}) ;
const mesh = new THREE.Mesh( geometry, material) ;
mesh.translateZ( Zact) ;
//mesh.applyMatrix4( Mat_LocToGlob) ;
//mesh.applyMatrix4( Mat_ThreeJs_Frame) ;
mesh.applyMatrix4( Mat_ToScene) ;
mesh.nLayer = nLayer ;
mesh.isArrow = false ;
layer_list.push( mesh) ;
} catch( err) {
console.log( ' Not a valid Layer for paths') ;
return false ;
}
}
// READING ARROW'S MESH
else if ( child.type == 'Mesh') {
try {
var nLayer = parseInt( child.userData.attributes.layerIndex) - nStartLayer ;
if ( nLayer < 0)
return false ;
child.isArrow = child.name == 'Arrow' ;
child.applyMatrix4( Mat_ThreeJs_Frame) ;
child.nLayer = nLayer ;
child.material.color = new THREE.Color( child.userData.attributes.objectColor.r/255.0,
child.userData.attributes.objectColor.g/255.0,
child.userData.attributes.objectColor.b/255.0) ;
child.material.flatShading = true;
child.material.needsUpdate = true;
layer_list.push( child) ;
} catch( e) {
console.log( 'Not a valid Arrow direction') ;
return false ;
}
}
// READING OTHER ENTITY --------------------
else
continue ;
}
AdaptSeceneToContest() ;
console.log(new Date()) ;
}) ;
let endTime = performance.now();
let timeElapsed = endTime - startTime;
console.log('init3dm in : ' + timeElapsed)
}, 0)
})
}
function refreshElement(nStart, nEnd) {
//console.log(parseInt(nStart));
m_nStartL = nStart;
m_nEndL = nEnd;
if(fileType == "3DM"){
for ( var i = 0 ; i < layer_list.length ; ++ i) {
if ( parseInt( layer_list[i].nLayer) >= nStart &&
parseInt( layer_list[i].nLayer) <= nEnd) {
if ( layer_list[i].isArrow)
layer_list[i].visible = m_bShowDir ;
else
layer_list[i].visible = true ;
}
else {
layer_list[i].visible = false ;
}
}
}
else if (fileType == "3MF"){
for ( var i = 0 ; i < layer_list.length ; ++ i) {
if ( parseInt( layer_list[i].children[0].nLayer) >= nStart &&
parseInt( layer_list[i].children[0].nLayer) <= nEnd) {
if ( layer_list[i].children[0].isArrow)
layer_list[i].visible = m_bShowDir ;
else
layer_list[i].visible = true ;
}
else {
layer_list[i].visible = false ;
}
}
}
render();
}
function AdaptSeceneToContest() {
scene = new THREE.Scene();
scene.background = new THREE.Color( 0xa0a0a0) ;
// Global Box ----------
if (fileType == "3DM") {
for ( var i = 0 ; i < layer_list.length ; ++ i) {
const Objbox = new THREE.Box3().setFromObject( layer_list[i]);
GLBox3D.union( Objbox) ;
layer_list[i].material.side = THREE.DoubleSide ;
layer_list[i].castShadow = true
if ( ! layer_list[i].isArrow || m_bShowPrintDir) {
if ( typeof layer_list[i].nLayer !== "undefined") {
if ( parseInt( layer_list[i].nLayer) % 2 == 0) {
const mat = layer_list[i].material.clone() ;
mat.color.lerp( new THREE.Color( 0x000000), 0.25) ;
layer_list[i].material = mat ;
}
}
layer_list[i].isArrow = ( layer_list[i].name == 'Arrow')
scene.add( layer_list[i]) ;
}
}
}
else if ( fileType == "3MF"){
for ( var i = 0 ; i < layer_list.length ; ++ i) {
if ( layer_list[i].children[0].type == 'Mesh') {
const Objbox = new THREE.Box3().setFromObject( layer_list[i]);
GLBox3D.union( Objbox) ;
layer_list[i].children[0].material.side = THREE.DoubleSide ;
if ( typeof layer_list[i].children[0].nLayer !== "undefined") {
if ( parseInt( layer_list[i].children[0].nLayer) % 2 == 0)
layer_list[i].children[0].material.color.lerp( new THREE.Color( 0x000000 ), 0.25) ;
layer_list[i].children[0].isArrow = ( layer_list[i].children[0].name == 'Arrow')
scene.add( layer_list[i]) ;
}
}
else if ( layer_list[i].type == 'Vector3')
ORIG = layer_list[i].children[0].clone() ;
}
}
const vtCenter = new THREE.Vector3( 0, 0, 0) ;
GLBox3D.getCenter( vtCenter) ;
const vtPosition = vtCenter.clone().multiplyScalar( 5) ;
const vtBoxDim = new THREE.Vector3( 0, 0, 0) ;
GLBox3D.getSize( vtBoxDim) ;
// orthographic and perspective camera ------
perspectiveCamera = new THREE.PerspectiveCamera( 35, window.innerWidth / window.innerHeight, 10, 300000 ) ;
orthographicCamera = new THREE.OrthographicCamera( window.innerWidth / - 2, window.innerWidth / 2,
window.innerHeight / 2, window.innerHeight / - 2,
-300000, 300000) ;
if ( ! m_bIsOrtographic)
activeCamera = perspectiveCamera ;
else
activeCamera = orthographicCamera ;
activeCamera.position.set( 2 * vtBoxDim.x, 2 * vtBoxDim.y, 2 * vtBoxDim.z) ;
activeCamera.lookAt( vtCenter.x, vtCenter.y, vtCenter.z) ;
scene.add( activeCamera) ;
// Hemisphere light --------
const hemiLight = new THREE.HemisphereLight( 0xffffff, 0x444444, 1.8) ;
hemiLight.position.set( vtCenter.x, vtCenter.y + 2 * vtBoxDim.y, vtCenter.z) ;
scene.add( hemiLight) ;
// direction light --------
const dirLight = new THREE.DirectionalLight( 0xffffff );
dirLight.position.set( vtPosition.x, vtPosition.y, vtPosition.z);
dirLight.castShadow = true;
dirLight.shadow.camera.top = 50;
dirLight.shadow.camera.bottom = - 25;
dirLight.shadow.camera.left = - 25;
dirLight.shadow.camera.right = 25;
dirLight.shadow.camera.near = 0.1;
dirLight.shadow.camera.far = 200;
dirLight.shadow.mapSize.set( 1024, 1024 );
scene.add( dirLight) ;
// render settings ---------
renderer = new THREE.WebGLRenderer( { antialias: true });
renderer.setPixelRatio( window.devicePixelRatio );
var container = document.getElementById( 'WebGL-Export') ;
container.style.height = m_divStartDimY + "px";
container.style.width = m_divStartDimX + "px";
renderer.setSize( m_divStartDimX, m_divStartDimY) ;
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap ;
container.appendChild( renderer.domElement) ;
var cont = document.getElementById('spinContainer');
container.removeChild(cont);
// orbit controls -------
controls = new OrbitControls( activeCamera, renderer.domElement );
controls.addEventListener( 'change', render );
controls.update() ;
// Orig conversion -----
if(fileType == "3DM"){
const points_array = [ new THREE.Vector3( ORIG.x, ORIG.y, ORIG.z)] ;
var ORIG_Geometry = new THREE.BufferGeometry() ;
ORIG_Geometry.setFromPoints( points_array) ;
var ORIG_Material = new THREE.PointsMaterial({ size: 5, sizeAttenuation : true, color : new THREE.Color( 0x000000)}) ;
var ptORIG = new THREE.Points( ORIG_Geometry, ORIG_Material) ;
ptORIG.position.x = ORIG.x ;
ptORIG.position.y = ORIG.y ;
ptORIG.position.z = ORIG.z ;
}
else if(fileType == "3MF"){
const points_array = [ new THREE.Vector3( 0, 0, 0)] ;
var ORIG_Geometry = new THREE.BufferGeometry() ;
ORIG_Geometry.setFromPoints( points_array) ;
var ORIG_Material = new THREE.PointsMaterial({ size: 5, sizeAttenuation : true, color : new THREE.Color( 0x000000)});
var ptORIG = new THREE.Points( ORIG_Geometry, ORIG_Material) ;
ptORIG.position.x = ORIG.x ;
ptORIG.position.y = ORIG.z ;
ptORIG.position.z = - ORIG.y ;
}
// inputs --------------
setCameraZoom( m_bZoom) ;
setCameraPan( m_bPan) ;
setCameraRot( m_bRot) ;
SetCameraPos( m_nCameraStartPos, ORIG) ;
// Frame
AddFrame( ptORIG) ;
// Grid
AddGrid( ptORIG) ;
// render
render() ;
}
function render() {
renderer.render( scene, activeCamera) ;
}
function SetOrig( ORIG) {
// qui in qualche modo imposto l'origine, ora impostata secondo il BozHelper
// ---- codice da cambiare
var posX = GLBox3D.min.x - 0.3 * ( GLBox3D.max.x - GLBox3D.min.x) ;
var posY = 0 ;
var posZ = GLBox3D.min.z + 1.3 * ( GLBox3D.max.z - GLBox3D.min.z) ;
//ORIG.geometry.translate( posX, posY, posZ) ;
ORIG.position.set( posX, posY, posZ) ;
// -----------------------
//scene.add( ORIG) ;
}
function setCameraZoom( bZoom) {
controls.enableZoom = bZoom ;
}
function setCameraPan( bPan) {
controls.enablePan = bPan ;
}
function setCameraRot( bRot) {
controls.enableRotate = bRot ;
}
function SetCameraPos( nPos, ptORIG) {
var nTraslFactor = 2.5 ;
var x ; var y ; var z ;
y = GLBox3D.max.y ; // fixed
switch( nPos) {
case 0 :
x = GLBox3D.min.x ;
z = 0.5 * ( GLBox3D.min.z + GLBox3D.max.z) ;
break ;
case 1 :
x = GLBox3D.min.x ;
z = GLBox3D.max.z ;
break ;
case 2 :
x = 0.5 * ( GLBox3D.min.x + GLBox3D.max.x) ;
z = GLBox3D.max.z ;
break ;
case 3 :
x = GLBox3D.max.x ;
z = GLBox3D.max.z ;
break ;
case 4 :
x = GLBox3D.max.x ;
z = 0.5 * ( GLBox3D.min.z + GLBox3D.max.z) ;
break ;
case 5 :
x = GLBox3D.max.x ;
z = GLBox3D.min.z ;
break ;
case 6 :
x = 0.5 * ( GLBox3D.min.x + GLBox3D.max.x) ;
z = GLBox3D.min.z ;
break ;
case 7 :
x = GLBox3D.min.x ;
z = GLBox3D.min.z ;
break ;
case 8 : // optimal
x = ( ORIG.x + 1.0 * Math.abs( GLBox3D.max.x - GLBox3D.min.x)) ;
z = ( ORIG.z + 1.0 * Math.abs( GLBox3D.max.z - GLBox3D.min.z)) ;
break ;
default :
return ;
}
var vtPos = new THREE.Vector3( x, y, z) ;
const vtCenter = new THREE.Vector3( 0, 0, 0) ; GLBox3D.getCenter( vtCenter) ;
var vtDirOut = new THREE.Vector3( vtPos.x - vtCenter.x, vtPos.y - vtCenter.y, vtPos.z - vtCenter.z) ;
vtDirOut.x *= nTraslFactor ; vtDirOut.y *= nTraslFactor ; vtDirOut.z *= nTraslFactor ;
activeCamera.position.set( x + vtDirOut.x, y + vtDirOut.y, z + vtDirOut.z) ;
controls.target.set( vtCenter.x, vtCenter.y, vtCenter.z) ;
controls.minZoom = 0.25 ;
controls.maxDistance = 1.1 * activeCamera.position.distanceTo( controls.target) ;
controls.update() ;
}
function toggleCamera( perspectiveCamera, orthographicCamera) {
var cameraPosition = activeCamera.position.clone() ;
var cameraMatrix = activeCamera.matrix.clone() ;
var ControlsTarget = controls.target.clone() ;
var ControlsPosition = controls.position0.clone() ;
if ( m_bIsOrtographic == true) {
m_bIsOrtographic = false ;
activeCamera = perspectiveCamera ;
activeCamera.position.copy( cameraPosition) ;
activeCamera.matrix.copy( cameraMatrix) ;
} else {
m_bIsOrtographic = true ;
activeCamera = orthographicCamera ;
activeCamera.position.copy( cameraPosition) ;
activeCamera.matrix.copy( cameraMatrix) ;
}
activeCamera.updateProjectionMatrix() ;
controls.object = activeCamera ;
controls.target = ControlsTarget ;
controls.position0 = ControlsPosition ;
controls.update() ;
render() ;
}
function AddFrame( ptORIG) {
if ( ! m_bShowFrame)
return ;
if ( m_bFrameType == 0) {
const axesHelper = new THREE.AxesHelper( m_lFrameLen) ;
axesHelper.rotation.set( -Math.PI/2, 0 , 0) ;
axesHelper.position.set( ptORIG.position.x, ptORIG.position.y, ptORIG.position.z) ;
scene.add( axesHelper ) ;
}
else if ( m_bFrameType == 1) {
var vtDirs = [ new THREE.Vector3( 1, 0, 0), new THREE.Vector3( 0, 0, -1), new THREE.Vector3( 0, 1, 0)] ;
var vtCols = [ new THREE.Color( 0xff0000), new THREE.Color( 0x00ff00), new THREE.Color( 0x0000ff)] ;
var vtORIG = new THREE.Vector3( ptORIG.position.x, ptORIG.position.y, ptORIG.position.z) ;
for ( var i = 0 ; i < 3 ; ++ i) {
const arrowHelper = new THREE.ArrowHelper( vtDirs[i], vtORIG, m_lFrameLen, vtCols[i]) ;
scene.add( arrowHelper ) ;
}
}
else if ( m_bFrameType == 2) {
var vtCols = [ new THREE.Color( 0x0000ff), new THREE.Color( 0xff0000), new THREE.Color( 0x00ff00)] ;
for ( var i = 0 ; i < 3 ; ++ i) {
// cylinder ----
const fr_geometry_cyl = new THREE.CylinderGeometry( m_dFrameFat, m_dFrameFat, 0.8 * m_lFrameLen, 32) ;
const fr_material = new THREE.MeshBasicMaterial({color: vtCols[i]}) ;
const fr_cylinder = new THREE.Mesh( fr_geometry_cyl, fr_material) ;
fr_cylinder.position.set( ptORIG.position.x, ptORIG.position.y, ptORIG.position.z) ;
if ( i == 1)
fr_cylinder.rotation.set( 0, 0, -Math.PI/2) ;
if ( i == 2)
fr_cylinder.rotation.set( -Math.PI/2, 0, 0) ;
scene.add( fr_cylinder) ;
fr_cylinder.translateY( 0.4 * m_lFrameLen) ;
// pyramid
const fr_geometry_cone = new THREE.CylinderGeometry( 0, 2 * m_dFrameFat, 0.2 * m_lFrameLen, 32) ;
const fr_cone = new THREE.Mesh( fr_geometry_cone, fr_material) ;
fr_cone.position.set( ptORIG.position.x, ptORIG.position.y, ptORIG.position.z) ;
if ( i == 1)
fr_cone.rotation.set( 0, 0, -Math.PI/2) ;
if ( i == 2)
fr_cone.rotation.set( -Math.PI/2, 0, 0) ;
scene.add( fr_cone) ;
fr_cone.translateY( 0.9 * m_lFrameLen) ;
}
// Origin
const fr_orig_geometry = new THREE.SphereGeometry( 2 * m_dFrameFat, 32, 16) ;
const fr_orig_material = new THREE.MeshBasicMaterial( {color: 0x00000}) ;
const fr_sphere = new THREE.Mesh( fr_orig_geometry, fr_orig_material) ;
fr_sphere.position.set( ptORIG.position.x, ptORIG.position.y, ptORIG.position.z) ;
scene.add( fr_sphere) ;
}
else
console.log( 'Frame type not defined') ;
}
function AddGrid( ptORIG) {
if ( ! m_bShowGrid)
return ;
const size = 1000000 ;
const divisions = 10000 ;
if ( m_bInfGrid) {
const gridHelper = new THREE.GridHelper( size, divisions) ;
gridHelper.position.set( ptORIG.position.x, ptORIG.position.y, ptORIG.position.z) ;
gridHelper.material.transparent = true ;
gridHelper.material.opacity = 0.25 ;
scene.add( gridHelper) ;
}
else {
var dDimX = Math.abs( GLBox3D.max.x - GLBox3D.min.x) ;
var dDimY = Math.abs( GLBox3D.max.y - GLBox3D.min.y) ;
var dDimZ = Math.abs( GLBox3D.max.z - GLBox3D.min.z) ;
var dDim = 1.5 * Math.sqrt( dDimX * dDimX + dDimY * dDimY + dDimZ * dDimZ) ;
const gridHelper = new THREE.GridHelper( dDim, Math.ceil( 0.1 * dDim)) ;
gridHelper.position.set( ptORIG.position.x + 0.5 * dDim , ptORIG.position.y, ptORIG.position.z - 0.5 * dDim) ;
gridHelper.material.transparent = true ;
gridHelper.material.opacity = 0.45 ;
scene.add( gridHelper) ;
}
}
function ShowPrintDir(showDir){
console.log(showDir);
m_bShowDir = showDir;
if(fileType == "3DM"){
for ( var i = 0 ; i < layer_list.length ; ++ i) {
if ( layer_list[i].isArrow) {
if ( layer_list[i].nLayer >= m_nStartL &&
layer_list[i].nLayer <= m_nEndL)
layer_list[i].visible = m_bShowDir ;
else
layer_list[i].visible = false ;
}
}
}
else if(fileType == "3MF"){
for ( var i = 0 ; i < layer_list.length ; ++ i) {
if ( layer_list[i].children[0].isArrow) {
if ( parseInt( layer_list[i].children[0].nLayer) >= m_nStartL &&
parseInt( layer_list[i].children[0].nLayer) <= m_nEndL)
layer_list[i].visible = m_bShowDir ;
else
layer_list[i].visible = false ;
}
}
}
render() ;
}
@@ -0,0 +1,7 @@
import Vue from 'vue'
import App from './App.vue'
new Vue({
el: '#app',
render: h => h(App)
})
@@ -0,0 +1,80 @@
var path = require('path')
var webpack = require('webpack')
module.exports = {
entry: './src/main.js',
output: {
path: path.resolve(__dirname, './dist'),
publicPath: '/dist/',
filename: 'build.js'
},
module: {
rules: [
{
test: /\.css$/,
use: [
'vue-style-loader',
'css-loader'
],
}, {
test: /\.vue$/,
loader: 'vue-loader',
options: {
loaders: {
}
// other vue-loader options go here
}
},
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.(png|jpg|gif|svg)$/,
loader: 'file-loader',
options: {
name: '[name].[ext]?[hash]'
}
}
]
},
resolve: {
alias: {
'vue$': 'vue/dist/vue.esm.js',
// "three": "../build/three.module.js",
// "three/addons/": "../jsm/"
},
extensions: ['*', '.js', '.vue', '.json']
},
devServer: {
historyApiFallback: true,
noInfo: true,
overlay: true
},
performance: {
hints: false
},
devtool: '#eval-source-map'
}
if (process.env.NODE_ENV === 'production') {
module.exports.devtool = '#source-map'
// http://vue-loader.vuejs.org/en/workflow/production.html
module.exports.plugins = (module.exports.plugins || []).concat([
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"'
}
}),
new webpack.optimize.UglifyJsPlugin({
sourceMap: true,
compress: {
warnings: false
}
}),
new webpack.LoaderOptionsPlugin({
minimize: true
})
])
}
+6
View File
@@ -0,0 +1,6 @@
{
"name": "Web3D-Vue",
"lockfileVersion": 3,
"requires": true,
"packages": {}
}
@@ -1,4 +1,4 @@
@page "/W3D"
@page "/w3d-slicer"
@using System.Runtime.InteropServices
@@ -6,7 +6,7 @@ using System.Reflection.Metadata.Ecma335;
namespace Web3D.pack.Pages
{
public partial class W3D : IDisposable
public partial class W3dSlicer : IDisposable
{
#region Protected Properties
@@ -46,6 +46,7 @@
<script type="module" src="~/lib/node_modules/webgl-visualizer/draw/webgl_drawCS.js"></script>
<script type="module" src="~/lib/webgl_help.js"></script>
<script type="module" src="~/lib/webgl_door_help.js"></script>
<script src="_framework/blazor.server.js"></script>
</body>
+87
View File
@@ -0,0 +1,87 @@
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.StaticFiles;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.FileProviders;
using Web3D.pack.Data;
var builder = WebApplication.CreateBuilder(args);
// configuration setup
Microsoft.Extensions.Configuration.ConfigurationManager configuration = builder.Configuration;
// Add services to the container.
builder.Services.AddRazorPages();
builder.Services.AddServerSideBlazor();
builder.Services.AddSingleton<WeatherForecastService>();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
var provider = new Microsoft.AspNetCore.StaticFiles.FileExtensionContentTypeProvider();
// NOTE: Add new mappings
provider.Mappings[".3mf"] = "model"; // NOTE: add the extension (with period) and its type
provider.Mappings[".3dm"] = "model"; // NOTE: add the extension (with period) and its type
// NOTE: comment this line of code out
// app.UseStaticFiles();
app.UseStaticFiles(new StaticFileOptions // NOTE: replace the line app.UseStaticFiles(); with this block of code
{
ContentTypeProvider = provider
});
// gestione static files x modelli 3D: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/static-files?view=aspnetcore-8.0
string path3mf = configuration.GetValue<string>("ServerConf:path3mf") ?? configuration.GetValue<string>("OptConf:path3mf") ?? "";
if (!string.IsNullOrEmpty(path3mf))
{
// verifico esista folder disegni
if (Directory.Exists(path3mf))
{
// gestione cartella x PDF
app.UseStaticFiles(new StaticFileOptions
{
FileProvider = new PhysicalFileProvider(path3mf),
RequestPath = "/3mf",
ContentTypeProvider = provider
});
}
}
string path3dm = configuration.GetValue<string>("ServerConf:path3dm") ?? configuration.GetValue<string>("OptConf:path3dm") ?? "";
if (!string.IsNullOrEmpty(path3dm))
{
// verifico esista folder disegni
if (Directory.Exists(path3dm))
{
// gestione cartella x PDF
app.UseStaticFiles(new StaticFileOptions
{
FileProvider = new PhysicalFileProvider(path3dm),
RequestPath = "/3dm",
ContentTypeProvider = provider
});
}
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.MapBlazorHub();
app.MapFallbackToPage("/_Host");
app.Run();
@@ -15,8 +15,8 @@
</NavLink>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link" href="W3D">
<span class="oi oi-list-rich" aria-hidden="true"></span> Test 3MF
<NavLink class="nav-link" href="w3d-slicer">
<span class="oi oi-badge" aria-hidden="true"></span> Test Slice 3mf
</NavLink>
</div>
</nav>
@@ -7,18 +7,22 @@
</PropertyGroup>
<ItemGroup>
<Content Include="wwwroot\lib\node_modules\.package-lock.json" />
<Content Include="wwwroot\lib\node_modules\webgl-visualizer\package.json" />
<Content Include="wwwroot\lib\node_modules\webgl-visualizer\styles\bottom.png" />
<Content Include="wwwroot\lib\node_modules\webgl-visualizer\styles\left.png" />
<Content Include="wwwroot\lib\node_modules\webgl-visualizer\styles\LogoClassic_NoText.png" />
<Content Include="wwwroot\lib\node_modules\webgl-visualizer\styles\right.png" />
<Content Include="wwwroot\lib\node_modules\webgl-visualizer\styles\SuperTopLogo.png" />
<Content Include="wwwroot\lib\node_modules\webgl-visualizer\styles\top.png" />
<Compile Remove="Temp\**" />
<Content Remove="Temp\**" />
<EmbeddedResource Remove="Temp\**" />
<None Remove="Temp\**" />
</ItemGroup>
<ItemGroup>
<Folder Include="Temp\" />
<Content Include="wwwroot\lib\node_modules\.package-lock.json" />
<Content Include="wwwroot\lib\node_modules\webgl-visualizer\models\.placeholder" />
<Content Include="wwwroot\lib\node_modules\webgl-visualizer\models\3mf\Cubo.3mf" />
<Content Include="wwwroot\lib\node_modules\webgl-visualizer\package.json" />
<Content Include="wwwroot\lib\node_modules\webgl-visualizer\styles\bottom.png" />
<Content Include="wwwroot\lib\node_modules\webgl-visualizer\styles\left.png" />
<Content Include="wwwroot\lib\node_modules\webgl-visualizer\styles\right.png" />
<Content Include="wwwroot\lib\node_modules\webgl-visualizer\styles\SuperTopLogo.png" />
<Content Include="wwwroot\lib\node_modules\webgl-visualizer\styles\top.png" />
</ItemGroup>
<ItemGroup>

Some files were not shown because too many files have changed in this diff Show More