storkCore

Diff
Login

Diff

Differences From Artifact [e97dc4ddc9]:

To Artifact [d5a636a631]:


42
43
44
45
46
47
48




49
50
51
52
53
54
55
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59







+
+
+
+







    height: "100%"
};

PoeViewController.bodypartMaxSize = "30%";
PoeViewController.bodypartID = null;
PoeViewController.breathingElements = [];
PoeViewController.locatorElements = [];

// JS timeout and interval references, for cancelling if needed.
PoeViewController.breatheTimeout = null;
PoeViewController.breatheInterval = null;

PoeViewController.copiedProperty("bodypartElements", []);

PoeViewController.setModel(PoeModel);

PoeViewController.setBodypartProto = function(element, bodypartSubID) {
    this.bodypartProto = element;
106
107
108
109
110
111
112
113
114
115
116
117
118
119



















120
121

122
123
124
125
126
127
128
110
111
112
113
114
115
116







117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136

137
138
139
140
141
142
143
144







-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

-
+







    return;
};


PoeViewController.refresh = function() {
    this.superMethod(PoeViewController.refresh, "refresh");
    console.debug("refresh");
};

PoeViewController.attach = function(parent) {
    this.superMethod(PoeViewController.attach, "attach", parent);
    this.breathingElements = [];
    this.locatorElements = [];
    
    /*
    if (this.breatheTimeout) {
        clearTimeout(this.breatheTimeout);
    }
    if (this.breatheInterval) {
        clearInterval(this.breatheInterval);
    }
    */

    // Remove old elements for regeneration
    for (let i=0; i < this.locatorElements.length; i++) {
        let el = this.locatorElements[i];
        el.parentNode.removeChild(el);
    } 
    for (let i=0; i < this.breathingElements.length; i++) {
        let el = this.breathingElements[i];
        el.parentNode.removeChild(el);
    }
    
    if ( (this.model != null) && (this.bodypartProto != null)  &&
         (this.bodyArea != null) ) {
         (this.bodyArea != null) && (this.getAttachedElement != null) ) {
        console.debug(this.model);
        console.debug(this.model.getProperty("bodypartNum"));
        for (i=0; i < this.model.getProperty("bodypartNum"); i++) {
            let locatorElement =
                cloneNodeSetIDs(this.bodypartProto, "PoeBody-", i);

            console.debug(Math.random() * this.movementDelayVariance + "s");
146
147
148
149
150
151
152
153

154
155
156
157
158
159

160











161
162
163
164
165
166
167




168
169
170
171

172
173
174
175

176
177
178
179
180
181
182
162
163
164
165
166
167
168

169
170
171
172
173
174

175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190




191
192
193
194
195
196
197

198
199
200
201

202
203
204
205
206
207
208
209







-
+





-
+

+
+
+
+
+
+
+
+
+
+
+



-
-
-
-
+
+
+
+



-
+



-
+







            //breathingElement.style.top = i * 10 + "px";
            //breathingElement.style.left = i * 10 + "px";
            breathingElement.style.transitionDelay =
                this.breathingTransitionDelay();
            breathingElement.style.transitionDuration =
                (Math.random() * this.breathingDurationVariance +
                 this.breathingDurationMin) + "s";
            parent.appendChild(locatorElement);
            this.getAttachedElement().appendChild(locatorElement);
            this.locatorElements.push(locatorElement);
            this.breathingElements.push(breathingElement);
        }
        
        // Set up some initial breath positions
        this.breathBody();
        this.breatheBody();
        this.refreshHtmlPosition();
    }    
};


PoeViewController.attach = function(parent) {
    console.debug("poe attach");
    this.superMethod(PoeViewController.attach, "attach", parent);
    
    this.breathingElements = [];
    this.locatorElements = [];
    
            
        // This is here to cause some breathing animation more rapidly
        // than the regular interval below it.
        setTimeout(() => {
            this.breathBody();
            setInterval(() => {
                this.breathBody();
        this.breatheTimeout = setTimeout(() => {
            this.breatheBody();
            this.breatheInterval = setInterval(() => {
                this.breatheBody();
            }, 6000);
        }, 1000);

    }
    this.refresh();
};


PoeViewController.breathBody = function() {
PoeViewController.breatheBody = function() {
    console.debug("called");

    for (let i=0; i < this.breathingElements.length; i++) {
        let scale = (Math.random() * 8 + 3) / 20;
        let x = Math.random() * 50-25;
        let y = Math.random() * 50-25;