bzselect now clean + KVview adapted
This commit is contained in:
1 parent
12e72f9c7f
commit
e3ca6bd6b2
5 files changed
+58
-56
No files matched your search
@@ -0,0 +1 @@
|
|||||||
|
{"glyphs":{"ο":{"x_min":0,"x_max":712,"ha":815,"o":"m 356 -25 q 96 88 192 -25 q 0 368 0 201 q 92 642 0 533 q 356 761 192 761 q 617 644 517 761 q 712 368 712 533 q 619 91 712 201 q 356 -25 520 -25 m 356 85 q 527 175 465 85 q 583 369 583 255 q 528 562 583 484 q 356 651 466 651 q 189 560 250 651 q 135 369 135 481 q 187 177 135 257 q 356 85 250 85 "},"S":{"x_min":0,"x_max":788,"ha":890,"o":"m 788 291 q 662 54 788 144 q 397 -26 550 -26 q 116 68 226 -26 q 0 337 0 168 l 131 337 q 200 152 131 220 q 384 85 269 85 q 557 129 479 85 q 650 270 650 183 q 490 429 650 379 q 194 513 341 470 q 33 739 33 584 q 142 964 33 881 q 388 1041 242 1041 q 644 957 543 1041 q 756 716 756 867 l 625 716 q 561 874 625 816 q 395 933 497 933 q 243 891 309 933 q 164 759 164 841 q 325 609 164 656 q 625 526 475 568 q 788 291 788 454 "},"¦":{"x_min":343,"x_max":449,"ha":792,"o":"m 449 462 l 343 462 l 343 986 l 449 986 l 449 462 m 449 -242 l 343 -242 l 343 280 l 449 280 l 449 -242 "},"/":{"x_min":183.25,"x_max":608.328125,"ha":792,"o":"m 608 1041 l 266 -129 l 183 -129 l 520 1041 l 608 1041 "},"Τ":{"x_min":-0.4375,"x_max":777.453125,"ha":839,"o":"m 777 893 l 458 893 l 458 0 l 319 0 l 319 892 l 0 892 l 0 1013 l 777 1013 l 777 893 "},"y":{"x_min":0,"x_max":684.78125,"ha":771,"o":"m 684 738 l 388 -83 q 311 -216 356 -167 q 173 -279 252 -279 q 97 -266 133 -279 l 97 -149 q 132 -155 109 -151 q 168 -160 155 -160 q 240 -114 213 -160 q 274 -26 248 -98 l 0 738 l 137 737 l 341 139 l 548 737 l 684 738 "},"Π":{"x_min":0,"x_max":803,"ha":917,"o":"m 803 0 l 667 0 l 667 886 l 140 886 l 140 0 l 0 0 l 0 1012 l 803 1012 l 803 0 "},"ΐ":{"x_min":-111,"x_max":339,"ha":361,"o":"m 339 800 l 229 800 l 229 925 l 339 925 l 339 800 m -1 800 l -111 800 l -111 925 l -1 925 l -1 800 m 284 3 q 233 -10 258 -5 q 182 -15 207 -15 q 85 26 119 -15 q 42 200 42 79 l 42 737 l 167 737 l 168 215 q 172 141 168 157 q 226 101 183 101 q 248 103 239 101 q 284 112 257 104 l 284 3 m 302 1040 l 113 819 l 30 819 l 165 1040 l 302 1040 "},"g":{"x_min":0,"x_max":686,"ha":838,"o":"m 686 34 q 586 -213 686 -121 q 331 -306 487 -306 q 131 -252 216 -306 q 31 -84 31 -190 l 155 -84 q 228 -174 166 -138 q 345 -207 284 -207 q 514 -109 454 -207 q 564 89 564 -27 q 461 6 521 36 q 335 -23 401 -23 q 88 100 184 -23 q 0 370 0 215 q 87 634 0 522 q 330 758 183 758 q 457 728 398 758 q 564 644 515 699 l 564 737 l 686 737 l 686 34 m 582 367 q 529 560 582 481 q 358 652 468 652 q 189 561 250 652 q 135 369 135 482 q 189 176 135 255 q 361 85 251 85 q 529 176 468 85 q 582 367 582 255 "},"²":{"x_min":0,"x_max":442,"ha":539,"o":"m 442 383 l 0 383 q 91 566 0 492 q 260 668 176 617 q 354 798 354 727 q 315 875 354 845 q 227 905 277 905 q 136 869 173 905 q 99 761 99 833 l 14 761 q 82 922 14 864 q 232 974 141 974 q 379 926 316 974 q 442 797 442 878 q 351 635 442 704 q 183 539 321 611 q 92 455 92 491 l 442 455 l 442 383 "},"–":{"x_min":0,"x_max":705.5625,"ha":803,"o":"m 705 334 l 0 334 l 0 410 l 705 410 l 705 334 "},"Κ":{"x_min":0,"x_max":819.5625,"ha":893,"o":"m 819 0 l 650 0 l 294 509 l 139 356 l 139 0 l 0 0 l 0 1013 l 139 1013 l 139 526 l 626 1013 l 809 1013 l 395 600 l 819 0 "},"ƒ":{"x_min":-46.265625,"x_max":392,"ha":513,"o":"m 392 651 l 259 651 l 79 -279 l -46 -278 l 134 651 l 14 651 l 14 751 l 135 751 q 151 948 135 900 q 304 1041 185 1041 q 334 1040 319 1041 q 392 1034 348 1039 l 392 922 q 337 931 360 931 q 271 883 287 931 q 260 793 260 853 l 260 751 l 392 751 l 392 651 "},"e":{"x_min":0,"x_max":714,"ha":813,"o":"m 714 326 l 140 326 q 200 157 140 227 q 359 87 260 87 q 488 130 431 87 q 561 245 545 174 l 697 245 q 577 48 670 123 q 358 -26 484 -26 q 97 85 195 -26 q 0 363 0 197 q 94 642 0 529 q 358 765 195 765 q 626 627 529 765 q 714 326 714 503 m 576 429 q 507 583 564 522 q 355 650 445 650 q 206 583 266 650 q 140 429 152 522 l 576 429 "},"ό":{"x_min":0,"x_max":712,"ha":815,"o":"m 356 -25 q 94 91 194 -25 q 0 368 0 202 q 92 642 0 533 q 356 761 192 761 q 617 644 517 761 q 712 368 712 533 q 619 91 712 201 q 356 -25 520 -25 m 356 85 q 527 175 465 85 q 583 369 583 255 q 528 562 583 484 q 356 651 466 651 q 189 560 250 651 q 135 369 135 481 q 187 177 135 257 q 356 85 250 85 m 576 1040 l 387 819 l 303 819 l 438 1040 l 576 1040 "},"J":{"x_min":0,"x_max":588,"ha":699,"o":"m 588 279 q 287 -26 588 -26 q 58 73 126 -26 q 0 327 0 158 l 133 327 q 160 172 133 227 q 288 96 198 96 q 426 171 391 96 q 449 336 449 219 l 449 1013 l 588 1013 l 588 279 "},"»":{"x_min":-1,"x_max":503,"ha":601,"o":"m 503 302 l 280 136 l 281 256 l 429 373 l 281 486 l 280 608 l 503 440 l 503 302 m 221 302 l 0 136 l 0 255 l 145 372 l 0 486 l -1 608 l 221 440 l 221 302 "},"©":{"x_min":-3,"x_max":1008,"ha":1106,"o":"m 502 -7 q 123 151 263 -7 q -3 501 -3 294 q 123 851 -3 706 q 502 1011 263 1011 q 881 851 739 1011 q 1008 501 1008 708 q 883 151 1008 292 q 502 -7 744 -7 m 502 60 q 830 197 709 60 q 940 501 940 322 q 831 805 940 681 q 502 944 709 944 q 174 805 296 944 q 65 501 65 680 q 173 197 65 320 q 502 60 294 60 m 741 394 q 661 246 731 302 q 496 190 591 190 q 294 285 369 Line truncated
|
||||||
Vendored
+45
-32
@@ -29,42 +29,41 @@ class Buildoz extends HTMLElement {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
attributeChangedCallback(name, oldValue, newValue) {
|
||||||
|
this.attrs[name] = newValue
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class BZselect extends Buildoz {
|
class BZselect extends Buildoz {
|
||||||
constructor(){
|
constructor(){
|
||||||
super()
|
super()
|
||||||
|
|
||||||
this.value = null
|
this.value = null
|
||||||
this.open = false
|
this.open = false
|
||||||
//defaults, can be changed by corresponding attributes
|
this.defaultAttrs = {
|
||||||
this.attrs = {
|
|
||||||
label: 'Select...',
|
label: 'Select...',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
connectedCallback() {
|
connectedCallback() {
|
||||||
super.connectedCallback()
|
super.connectedCallback()
|
||||||
|
|
||||||
this.button = document.createElement('button')
|
this.button = document.createElement('button')
|
||||||
this.button.textContent = this.attrs.label
|
this.button.textContent = this.getAttribute('label') || this.defaultAttrs.label
|
||||||
this.prepend(this.button)
|
this.prepend(this.button)
|
||||||
this.button.addEventListener('click', this.toggle.bind(this))
|
this.button.addEventListener('click', this.toggle.bind(this))
|
||||||
this.options = this.querySelectorAll('option')
|
this.options = this.querySelectorAll('option')
|
||||||
for(const opt of this.options){
|
for(const opt of this.options){
|
||||||
opt.addEventListener('click',(evt) => { this.onOption(evt.target.value) })
|
opt.addEventListener('click', this.onClick.bind(this))
|
||||||
|
if(opt.getAttribute('selected') !== null) this.onOption(opt.value, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static get observedAttributes(){
|
// static get observedAttributes(){ // Only if you want actions on attr change
|
||||||
return([...super.observedAttributes, 'label'])
|
// return([...super.observedAttributes, 'myattr'])
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
attributeChangedCallback(name, oldValue, newValue) {
|
// attributeChangedCallback(name, oldValue, newValue) {
|
||||||
this.attrs[name] = newValue
|
// super.attributeChangedCallback(name, oldValue, newValue)
|
||||||
// on the fly changes here
|
// }
|
||||||
}
|
|
||||||
|
|
||||||
toggle(){
|
toggle(){
|
||||||
for(const opt of this.options){
|
for(const opt of this.options){
|
||||||
@@ -74,26 +73,40 @@ class BZselect extends Buildoz {
|
|||||||
this.open = !this.open
|
this.open = !this.open
|
||||||
}
|
}
|
||||||
|
|
||||||
onOption(value){
|
onClick(evt){
|
||||||
this.value =value
|
const opt = evt.target.closest('option')
|
||||||
this.toggle()
|
if(opt && opt.value) this.onOption(opt.value)
|
||||||
const opt = Array.from(this.options).find(opt => opt.value==value)
|
|
||||||
this.button.textContent = opt.textContent
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fill(opts){
|
onOption(value, silent=false){
|
||||||
this.el.innerHTML =''
|
this.value = value
|
||||||
if(!Array.isArray(opts)) opts = [opts]
|
if(!silent) this.toggle()
|
||||||
const ul = Object.assign(document.createElement('ul'),
|
const opt = Array.from(this.options).find(opt => opt.value==value)
|
||||||
{ className: `bz-selector ${this.config.ulClass ? this.config.ulClass :''}`,
|
if(value || (opt && opt.textContent)) this.button.textContent = opt.textContent
|
||||||
})
|
else this.button.textContent = this.getAttribute('label') || this.defaultAttrs.label
|
||||||
for(const opt of opts){
|
this.dispatchEvent(new Event('change', {
|
||||||
const li = document.createElement('li')
|
bubbles: true,
|
||||||
li.innerHTML = `${opt.markup}`
|
composed: false,
|
||||||
li.setAttribute('data-value', opt.value)
|
cancelable: false
|
||||||
ul.append(li)
|
}))
|
||||||
}
|
}
|
||||||
this.el.append(ul)
|
|
||||||
|
addOption(value, markup){
|
||||||
|
const opt = document.createElement('option')
|
||||||
|
opt.setAttribute(value, value)
|
||||||
|
opt.innerHTML = markup
|
||||||
|
opt.addEventListener('click',this.onClick.bind(this))
|
||||||
|
this.append(opt)
|
||||||
|
this.options = this.querySelectorAll('option')
|
||||||
|
}
|
||||||
|
|
||||||
|
fillOptions(opts, erase = true){
|
||||||
|
if(erase){
|
||||||
|
this.options.forEach(node => { node.remove() })
|
||||||
|
this.options = this.querySelectorAll('option')
|
||||||
|
this.onOption('', true) // unselect last
|
||||||
|
}
|
||||||
|
for(const opt of opts) this.addOption(opt.value, opt.markup)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,13 +17,7 @@
|
|||||||
<article eiccard class="agent-preview">
|
<article eiccard class="agent-preview">
|
||||||
<header><canvas data-output="agentSampleCanvas"></canvas></header>
|
<header><canvas data-output="agentSampleCanvas"></canvas></header>
|
||||||
<section>
|
<section>
|
||||||
<bz-select label="Agent type..." data-output="agentsSelector">
|
<bz-select label="Agent type..." data-output="agentsSelector"></bz-select>
|
||||||
<option value="val1">First value</option>
|
|
||||||
<option value="val2">Second value</option>
|
|
||||||
<option value="val3">Third value</option>
|
|
||||||
<option value="val4">Fourth value</option>
|
|
||||||
<option value="val5">Fifth value</option>
|
|
||||||
</bz-select>
|
|
||||||
</section>
|
</section>
|
||||||
</article>
|
</article>
|
||||||
<article eiccard>
|
<article eiccard>
|
||||||
|
|||||||
@@ -21,28 +21,21 @@ class KeyframeView extends WindozDomContent {
|
|||||||
this.setupTriggers(components)
|
this.setupTriggers(components)
|
||||||
this.setupRefs(components)
|
this.setupRefs(components)
|
||||||
|
|
||||||
|
|
||||||
this.agentDefs = await this.models.agents.getSprites('Basic 3D')
|
this.agentDefs = await this.models.agents.getSprites('Basic 3D')
|
||||||
// for(const agentType in this.agentDefs){
|
this.outputs.agentsSelector.fillOptions( Object.keys(this.agentDefs).map(aname => ({ markup: `<i>${aname}</i>`, value: aname})) )
|
||||||
// const opt = new Option(agentType, agentType)
|
this.outputs.agentsSelector.addEventListener('change',this.onChangeAgent.bind(this))
|
||||||
// this.outputs.agentsSelector.add(opt)
|
|
||||||
// }
|
|
||||||
// this.outputs.agentsSelector.addEventListener('change',this.onChangeAgent.bind(this))
|
|
||||||
|
|
||||||
// const x = new tinySelector('[data-output="agentsSelector"]',{
|
this.agentPreview = new app.LoadedModules.AgentPreview(this.outputs.agentSampleCanvas, this.agentDefs)
|
||||||
// selectorOptions: Object.keys(this.agentDefs).map(aname => ({ markup: aname, value: aname}))
|
this.onChangeAgent()
|
||||||
// })
|
this.agentPreview.startRendering()
|
||||||
|
this.agentPreview.animation = true
|
||||||
// this.agentPreview = new app.LoadedModules.AgentPreview(this.outputs.agentSampleCanvas, this.agentDefs)
|
|
||||||
// this.onChangeAgent()
|
|
||||||
// this.agentPreview.startRendering()
|
|
||||||
// this.agentPreview.animation = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
onChangeAgent(event){
|
onChangeAgent(event){
|
||||||
this.agentPreview.setAgent(this.outputs.agentsSelector.value)
|
console.log('onChangeAgent',this.outputs.agentsSelector.value)
|
||||||
|
if(this.outputs.agentsSelector.value) this.agentPreview.setAgent(this.outputs.agentsSelector.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,11 +61,12 @@ export class AgentPreview{
|
|||||||
return(this._animation)
|
return(this._animation)
|
||||||
}
|
}
|
||||||
|
|
||||||
_animate = () => { // to avoid havind to bind(this) in requestAnimationFrame, because one bound fn per frame = continuous GC load
|
_animate = () => { // to avoid having to bind(this) in requestAnimationFrame, because one bound fn per frame = continuous GC load
|
||||||
if(!this.animation) return
|
|
||||||
requestAnimationFrame(this._animate)
|
requestAnimationFrame(this._animate)
|
||||||
|
if(this.currentAgentObj && this.animation){
|
||||||
this.currentAgentObj.rotation.x += 0.005
|
this.currentAgentObj.rotation.x += 0.005
|
||||||
this.currentAgentObj.rotation.y += 0.01
|
this.currentAgentObj.rotation.y += 0.01
|
||||||
|
}
|
||||||
this.renderer.render(this.scene, this.camera)
|
this.renderer.render(this.scene, this.camera)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user