-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
08add5f
commit 044c1d9
Showing
20 changed files
with
263 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
//import "./index.css" | ||
//import "./css/main.css"; | ||
//import "./css/changeme.css" | ||
import Alpine from 'alpinejs' | ||
import 'htmx.org'; | ||
import "./viewer/main.js" | ||
window.Alpine = Alpine | ||
Alpine.start() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { createViewer3D } from "./viewer" | ||
|
||
var viewer = null; | ||
var models = []; | ||
var viewerEl = null; | ||
(function () { | ||
viewerEl = document.getElementById('viewer') | ||
if (viewerEl) { | ||
setControlEvents(viewerEl); | ||
viewer = createViewer3D(viewerEl.querySelector('.viewer-container')); | ||
viewer.setModels(models.map(m => { return { id: m } })); | ||
} | ||
document.body.addEventListener('htmx:load', function (evt) { | ||
var newViewerEl = evt.detail.elt.querySelector('.viewer-container'); | ||
if (newViewerEl) { | ||
console.log('newViewerEl', newViewerEl) | ||
if (viewer) { | ||
console.log('destroying viewer') | ||
//viewer.destroy(); | ||
} | ||
// initialize buttons for the view wrapper | ||
console.log('creating viewer') | ||
//viewer = createViewer3D(newViewerEl); | ||
//viewer.setModels(models.map(m => { return { id: m } })); | ||
} | ||
addListeners(); | ||
}); | ||
})() | ||
|
||
function addListeners() { | ||
document.querySelectorAll('button.add-model').forEach((el) => { | ||
el.addEventListener('click', function (e) { | ||
var m = e.currentTarget.dataset.modelId; | ||
if (models.indexOf(m) === -1) { | ||
models.push(m); | ||
} | ||
viewerEl.classList.remove('hidden'); | ||
viewer.setModels(models.map(m => { return { id: m } })); | ||
}) | ||
}) | ||
} | ||
|
||
function setControlEvents(viewerEl) { | ||
if (!viewerEl) { | ||
return; | ||
} | ||
viewerEl.querySelector('.close').addEventListener('click', function (e) { | ||
viewerEl.classList.add('hidden'); | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,22 @@ | ||
import { createViewer3D } from "./viewer" | ||
import Alpine from 'alpinejs' | ||
|
||
var viewer = null; | ||
var models = []; | ||
var viewerEl = null; | ||
(function () { | ||
viewerEl = document.getElementById('viewer') | ||
setControlEvents(viewerEl); | ||
|
||
document.body.addEventListener('htmx:load', function (evt) { | ||
var newViewerEl = evt.detail.elt.querySelector('.viewer-container'); | ||
if (newViewerEl) { | ||
console.log('newViewerEl', newViewerEl) | ||
if (viewer) { | ||
console.log('destroying viewer') | ||
viewer.destroy(); | ||
} | ||
// initialize buttons for the view wrapper | ||
console.log('creating viewer') | ||
viewer = createViewer3D(newViewerEl); | ||
viewer.setModels(models.map(m => { return { id: m } })); | ||
Alpine.store('lib', () => ({ | ||
models: [], | ||
viewer: null, | ||
init() { | ||
Alpine.store('context').current = 'lib' | ||
if (!this.$refs.libGlobSidebar) { | ||
console.log('no sidebar') | ||
document.getElementsByTagName('body')[0] | ||
.dispatchEvent(new CustomEvent("load-side", { | ||
detail: { context: 'lib' } | ||
})) | ||
} else { | ||
console.log('sidebar exists') | ||
this.viewer = createViewer3D(this.$refs.viewerContainer); | ||
this.viewer.setModels(this.models.map(m => { return { id: m } })); | ||
} | ||
addListeners(); | ||
}); | ||
})() | ||
|
||
function addListeners() { | ||
document.querySelectorAll('button.add-model').forEach((el) => { | ||
el.addEventListener('click', function (e) { | ||
var m = e.currentTarget.dataset.modelId; | ||
if (models.indexOf(m) === -1) { | ||
models.push(m); | ||
} | ||
viewerEl.classList.remove('hidden'); | ||
viewer.setModels(models.map(m => { return { id: m } })); | ||
}) | ||
}) | ||
} | ||
|
||
function setControlEvents(viewerEl) { | ||
if (!viewerEl) { | ||
return; | ||
} | ||
viewerEl.querySelector('.close').addEventListener('click', function (e) { | ||
viewerEl.classList.add('hidden'); | ||
}) | ||
} | ||
}, | ||
})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"dependencies": { | ||
"alpinejs": "^3.14.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package comp | ||
|
||
templ GlobSidebar() { | ||
<aside | ||
id="right-aside" | ||
hx-swap-oob="true" | ||
> | ||
<ul | ||
class="menu bg-base-200 rounded-box" | ||
> | ||
<li> | ||
<a | ||
class="tooltip tooltip-right" | ||
data-tip="Home" | ||
hx-get="/" | ||
> | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
class="h-5 w-5" | ||
fill="none" | ||
viewBox="0 0 24 24" | ||
stroke="currentColor" | ||
> | ||
<path | ||
stroke-linecap="round" | ||
stroke-linejoin="round" | ||
stroke-width="2" | ||
d="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6" | ||
></path> | ||
</svg> | ||
</a> | ||
</li> | ||
</ul> | ||
<div class="asset-side-wrapper"> | ||
<div class="asset-side-slot"></div> | ||
@View3D() | ||
</div> | ||
</aside> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package web | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/eduardooliveira/stLib/v2/library/web/comp" | ||
"github.com/eduardooliveira/stLib/v2/web" | ||
) | ||
|
||
func (h webHandler) sidebarHandler(r *http.Request) web.ResponseModel { | ||
return web.ResponseModel{ | ||
S: http.StatusOK, | ||
Component: comp.View3D(), | ||
IsFragment: true, | ||
} | ||
} |
Oops, something went wrong.