wco_models 3.1.0.325 → 3.4.0.3

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.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/stylesheets/production_theme.scss +4 -1
  3. data/app/assets/stylesheets/wco/main.scss +4 -0
  4. data/app/assets/stylesheets/wco/studio.scss +12 -4
  5. data/app/controllers/wco/api/newspartials_controller.rb +1 -1
  6. data/app/controllers/wco/api/newsproducer_controller.rb +5 -0
  7. data/app/controllers/wco/newspartials_controller.rb +1 -0
  8. data/app/models/iro/datapoint.rb +1 -1
  9. data/app/models/iro/option.rb +16 -2
  10. data/app/models/iro/position.rb +4 -6
  11. data/app/models/iro/priceitem.rb +42 -4
  12. data/app/models/iro/purse.rb +2 -0
  13. data/app/models/iro/stock.rb +1 -2
  14. data/app/models/tda/option.rb +4 -9
  15. data/app/models/wco/newspartial.rb +12 -4
  16. data/app/views/wco/api/newsproducer/README_newsproducer.txt +12 -0
  17. data/app/views/wco/api/newsproducer/_scenes.js-bk +20 -0
  18. data/app/views/wco/api/newsproducer/_scenes.js.erb +15 -0
  19. data/app/views/wco/api/newsproducer/{_studio_blue.js → _studio_blue1.js} +4 -1
  20. data/app/views/wco/api/newsproducer/_studio_blue2.js +912 -0
  21. data/app/views/wco/api/newsproducer/_studio_coc.js +769 -0
  22. data/app/views/wco/api/newsproducer/_studio_coc.js-bk +389 -0
  23. data/app/views/wco/api/newsproducer/_studio_coc.js-cannon +677 -0
  24. data/app/views/wco/api/newsproducer/_studio_fps.js +1018 -0
  25. data/app/views/wco/api/newsproducer/_studio_ra2.js +255 -0
  26. data/app/views/wco/api/newsproducer/_touch_controls.js +708 -0
  27. data/app/views/wco/api/newsproducer/_touch_pad.css +200 -0
  28. data/app/views/wco/api/newsproducer/games_fps.html +504 -0
  29. data/app/views/wco/api/newsproducer/{studio_green.html.erb → studio_blue0.html.erb} +1 -1
  30. data/app/views/wco/api/newsproducer/{studio_blue.html.erb → studio_blue1.html.erb} +3 -3
  31. data/app/views/wco/api/newsproducer/studio_blue2.html.erb +146 -0
  32. data/app/views/wco/api/newsproducer/studio_coc.html.erb +95 -0
  33. data/app/views/wco/api/newsproducer/studio_fps.html.erb +199 -0
  34. data/app/views/wco/api/newsproducer/studio_ra2.html.erb +95 -0
  35. data/app/views/wco/newspartials/_show_in_newsvideo.haml +6 -7
  36. data/app/views/wco/newspartials/index.haml-trash +6 -0
  37. data/config/initializers/08_integrations.rb +14 -1
  38. data/config/initializers/08_integrations.rb-example +0 -2
  39. data/config/routes.rb +3 -0
  40. data/lib/shortcuts.rb +1 -1
  41. metadata +23 -7
  42. data/app/views/wco/api/newsproducer/README.txt +0 -2
  43. /data/app/views/wco/api/newsproducer/{_studio_green.js → _studio_blue0.js} +0 -0
@@ -0,0 +1,389 @@
1
+ import * as THREE from 'three'
2
+ import Stats from 'three/addons/libs/stats.module.js'
3
+
4
+ import * as CANNON from 'cannon-es'
5
+ import CannonDebugger from 'cannon-es-debugger'
6
+
7
+ const scene = new THREE.Scene()
8
+
9
+ const light = new THREE.DirectionalLight()
10
+ light.position.set(25, 50, 25)
11
+ light.castShadow = true
12
+ light.shadow.mapSize.width = 16384
13
+ light.shadow.mapSize.height = 16384
14
+ light.shadow.camera.near = 0.5
15
+ light.shadow.camera.far = 100
16
+ light.shadow.camera.top = 100
17
+ light.shadow.camera.bottom = -100
18
+ light.shadow.camera.left = -100
19
+ light.shadow.camera.right = 100
20
+ scene.add(light)
21
+
22
+ const helper = new THREE.CameraHelper(light.shadow.camera)
23
+ scene.add(helper)
24
+
25
+ let width = 854
26
+ let height = 480
27
+ const fps = 30
28
+
29
+ const camera = new THREE.PerspectiveCamera(
30
+ 75,
31
+ width / height,
32
+ 0.1,
33
+ 1000
34
+ )
35
+ const chaseCam = new THREE.Object3D()
36
+ chaseCam.position.set(0, 0, 0)
37
+ const chaseCamPivot = new THREE.Object3D()
38
+ chaseCamPivot.position.set(0, 2, 4)
39
+ chaseCam.add(chaseCamPivot)
40
+ scene.add(chaseCam)
41
+
42
+ const container = document.getElementById('rotatingC')
43
+ container.style.touchAction = 'none'
44
+ container.style.width = width + 'px'
45
+ container.style.height = height + 'px'
46
+
47
+ const renderer = new THREE.WebGLRenderer()
48
+ renderer.setPixelRatio(window.devicePixelRatio)
49
+ renderer.setSize(width, height)
50
+ renderer.shadowMap.enabled = true
51
+ renderer.shadowMap.type = THREE.PCFSoftShadowMap
52
+ container.appendChild(renderer.domElement)
53
+
54
+ const phongMaterial = new THREE.MeshPhongMaterial()
55
+
56
+ const world = new CANNON.World()
57
+ world.gravity.set(0, -9.82, 0)
58
+
59
+ const groundMaterial = new CANNON.Material('groundMaterial')
60
+ groundMaterial.friction = 0.25
61
+ groundMaterial.restitution = 0.25
62
+
63
+ const wheelMaterial = new CANNON.Material('wheelMaterial')
64
+ wheelMaterial.friction = 0.25
65
+ wheelMaterial.restitution = 0.25
66
+
67
+ //ground
68
+ const groundGeometry = new THREE.PlaneGeometry(100, 100)
69
+ const groundMesh = new THREE.Mesh(groundGeometry, phongMaterial)
70
+ groundMesh.rotateX(-Math.PI / 2)
71
+ groundMesh.receiveShadow = true
72
+ scene.add(groundMesh)
73
+ const groundShape = new CANNON.Box(new CANNON.Vec3(50, 1, 50))
74
+ const groundBody = new CANNON.Body({ mass: 0, material: groundMaterial })
75
+ groundBody.addShape(groundShape)
76
+ groundBody.position.set(0, -1, 0)
77
+ world.addBody(groundBody)
78
+
79
+ //jumps
80
+ for (let i = 0; i < 100; i++) {
81
+ const jump = new THREE.Mesh(
82
+ new THREE.CylinderGeometry(0, 1, 0.5, 5),
83
+ phongMaterial
84
+ )
85
+ jump.position.x = Math.random() * 100 - 50
86
+ jump.position.y = 0.5
87
+ jump.position.z = Math.random() * 100 - 50
88
+ scene.add(jump)
89
+
90
+ const cylinderShape = new CANNON.Cylinder(0.01, 1, 0.5, 5)
91
+ const cylinderBody = new CANNON.Body({ mass: 0 })
92
+ cylinderBody.addShape(cylinderShape, new CANNON.Vec3())
93
+ cylinderBody.position.x = jump.position.x
94
+ cylinderBody.position.y = jump.position.y
95
+ cylinderBody.position.z = jump.position.z
96
+ world.addBody(cylinderBody)
97
+ }
98
+
99
+ const carBodyGeometry = new THREE.BoxGeometry(1, 1, 2)
100
+ const carBodyMesh = new THREE.Mesh(carBodyGeometry, phongMaterial)
101
+ carBodyMesh.position.y = 3
102
+ carBodyMesh.castShadow = true
103
+ scene.add(carBodyMesh)
104
+ carBodyMesh.add(chaseCam)
105
+
106
+ const carBodyShape = new CANNON.Box(new CANNON.Vec3(0.5, 0.5, 1))
107
+ const carBody = new CANNON.Body({ mass: 1 })
108
+ carBody.addShape(carBodyShape)
109
+ carBody.position.x = carBodyMesh.position.x
110
+ carBody.position.y = carBodyMesh.position.y
111
+ carBody.position.z = carBodyMesh.position.z
112
+ world.addBody(carBody)
113
+
114
+ //front left wheel
115
+ const wheelLFGeometry = new THREE.CylinderGeometry(
116
+ 0.33,
117
+ 0.33,
118
+ 0.2
119
+ )
120
+ wheelLFGeometry.rotateZ(Math.PI / 2)
121
+ const wheelLFMesh = new THREE.Mesh(wheelLFGeometry, phongMaterial)
122
+ wheelLFMesh.position.x = -1
123
+ wheelLFMesh.position.y = 3
124
+ wheelLFMesh.position.z = -1
125
+ wheelLFMesh.castShadow = true
126
+ scene.add(wheelLFMesh)
127
+ const wheelLFShape = new CANNON.Sphere(0.33)
128
+ const wheelLFBody = new CANNON.Body({ mass: 1, material: wheelMaterial })
129
+ wheelLFBody.addShape(wheelLFShape)
130
+ wheelLFBody.position.x = wheelLFMesh.position.x
131
+ wheelLFBody.position.y = wheelLFMesh.position.y
132
+ wheelLFBody.position.z = wheelLFMesh.position.z
133
+ world.addBody(wheelLFBody)
134
+
135
+ //front right wheel
136
+ const wheelRFGeometry = new THREE.CylinderGeometry(
137
+ 0.33,
138
+ 0.33,
139
+ 0.2
140
+ )
141
+ wheelRFGeometry.rotateZ(Math.PI / 2)
142
+ const wheelRFMesh = new THREE.Mesh(wheelRFGeometry, phongMaterial)
143
+ wheelRFMesh.position.y = 3
144
+ wheelRFMesh.position.x = 1
145
+ wheelRFMesh.position.z = -1
146
+ wheelRFMesh.castShadow = true
147
+ scene.add(wheelRFMesh)
148
+ const wheelRFShape = new CANNON.Sphere(0.33)
149
+ const wheelRFBody = new CANNON.Body({ mass: 1, material: wheelMaterial })
150
+ wheelRFBody.addShape(wheelRFShape)
151
+ wheelRFBody.position.x = wheelRFMesh.position.x
152
+ wheelRFBody.position.y = wheelRFMesh.position.y
153
+ wheelRFBody.position.z = wheelRFMesh.position.z
154
+ world.addBody(wheelRFBody)
155
+
156
+ //back left wheel
157
+ const wheelLBGeometry = new THREE.CylinderGeometry(
158
+ 0.4,
159
+ 0.4,
160
+ 0.33
161
+ )
162
+ wheelLBGeometry.rotateZ(Math.PI / 2)
163
+ const wheelLBMesh = new THREE.Mesh(wheelLBGeometry, phongMaterial)
164
+ wheelLBMesh.position.y = 3
165
+ wheelLBMesh.position.x = -1
166
+ wheelLBMesh.position.z = 1
167
+ wheelLBMesh.castShadow = true
168
+ scene.add(wheelLBMesh)
169
+ const wheelLBShape = new CANNON.Sphere(0.4)
170
+ const wheelLBBody = new CANNON.Body({ mass: 1, material: wheelMaterial })
171
+ wheelLBBody.addShape(wheelLBShape)
172
+ wheelLBBody.position.x = wheelLBMesh.position.x
173
+ wheelLBBody.position.y = wheelLBMesh.position.y
174
+ wheelLBBody.position.z = wheelLBMesh.position.z
175
+ world.addBody(wheelLBBody)
176
+
177
+ //back right wheel
178
+ const wheelRBGeometry = new THREE.CylinderGeometry(
179
+ 0.4,
180
+ 0.4,
181
+ 0.33
182
+ )
183
+ wheelRBGeometry.rotateZ(Math.PI / 2)
184
+ const wheelRBMesh = new THREE.Mesh(wheelRBGeometry, phongMaterial)
185
+ wheelRBMesh.position.y = 3
186
+ wheelRBMesh.position.x = 1
187
+ wheelRBMesh.position.z = 1
188
+ wheelRBMesh.castShadow = true
189
+ scene.add(wheelRBMesh)
190
+ const wheelRBShape = new CANNON.Sphere(0.4)
191
+ const wheelRBBody = new CANNON.Body({ mass: 1, material: wheelMaterial })
192
+ wheelRBBody.addShape(wheelRBShape)
193
+ wheelRBBody.position.x = wheelRBMesh.position.x
194
+ wheelRBBody.position.y = wheelRBMesh.position.y
195
+ wheelRBBody.position.z = wheelRBMesh.position.z
196
+ world.addBody(wheelRBBody)
197
+
198
+ const leftFrontAxis = new CANNON.Vec3(1, 0, 0)
199
+ const rightFrontAxis = new CANNON.Vec3(1, 0, 0)
200
+ const leftBackAxis = new CANNON.Vec3(1, 0, 0)
201
+ const rightBackAxis = new CANNON.Vec3(1, 0, 0)
202
+
203
+ const constraintLF = new CANNON.HingeConstraint(carBody, wheelLFBody, {
204
+ pivotA: new CANNON.Vec3(-1, -0.5, -1),
205
+ axisA: leftFrontAxis,
206
+ maxForce: 0.99,
207
+ })
208
+ world.addConstraint(constraintLF)
209
+ const constraintRF = new CANNON.HingeConstraint(carBody, wheelRFBody, {
210
+ pivotA: new CANNON.Vec3(1, -0.5, -1),
211
+ axisA: rightFrontAxis,
212
+ maxForce: 0.99,
213
+ })
214
+ world.addConstraint(constraintRF)
215
+ const constraintLB = new CANNON.HingeConstraint(carBody, wheelLBBody, {
216
+ pivotA: new CANNON.Vec3(-1, -0.5, 1),
217
+ axisA: leftBackAxis,
218
+ maxForce: 0.99,
219
+ })
220
+ world.addConstraint(constraintLB)
221
+ const constraintRB = new CANNON.HingeConstraint(carBody, wheelRBBody, {
222
+ pivotA: new CANNON.Vec3(1, -0.5, 1),
223
+ axisA: rightBackAxis,
224
+ maxForce: 0.99,
225
+ })
226
+ world.addConstraint(constraintRB)
227
+
228
+ //rear wheel drive
229
+ constraintLB.enableMotor()
230
+ constraintRB.enableMotor()
231
+
232
+ const keyMap = {}
233
+ const onDocumentKey = (e) => {
234
+ keyMap[e.code] = e.type === 'keydown'
235
+ }
236
+
237
+ let forwardVelocity = 0
238
+ let rightVelocity = 0
239
+
240
+ document.addEventListener('keydown', onDocumentKey, false)
241
+ document.addEventListener('keyup', onDocumentKey, false)
242
+
243
+ window.addEventListener('resize', onWindowResize, false)
244
+ function onWindowResize() {
245
+ camera.aspect = width / height
246
+ camera.updateProjectionMatrix()
247
+ renderer.setSize(width, height)
248
+ render()
249
+ }
250
+
251
+ const stats = new Stats()
252
+ document.body.appendChild(stats.dom)
253
+
254
+ const timer = new THREE.Timer()
255
+ let delta
256
+
257
+ const cannonDebugRenderer = new CannonDebugger(scene, world)
258
+
259
+ const v = new THREE.Vector3()
260
+ let thrusting = false
261
+
262
+ function animate() {
263
+ requestAnimationFrame(animate)
264
+
265
+ helper.update()
266
+
267
+ delta = Math.min(timer.update().getDelta(), 0.1)
268
+ world.step(delta)
269
+
270
+ cannonDebugRenderer.update()
271
+
272
+ // Copy coordinates from Cannon to Three.js
273
+ carBodyMesh.position.set(
274
+ carBody.position.x,
275
+ carBody.position.y,
276
+ carBody.position.z
277
+ )
278
+ carBodyMesh.quaternion.set(
279
+ carBody.quaternion.x,
280
+ carBody.quaternion.y,
281
+ carBody.quaternion.z,
282
+ carBody.quaternion.w
283
+ )
284
+
285
+ wheelLFMesh.position.set(
286
+ wheelLFBody.position.x,
287
+ wheelLFBody.position.y,
288
+ wheelLFBody.position.z
289
+ )
290
+ wheelLFMesh.quaternion.set(
291
+ wheelLFBody.quaternion.x,
292
+ wheelLFBody.quaternion.y,
293
+ wheelLFBody.quaternion.z,
294
+ wheelLFBody.quaternion.w
295
+ )
296
+
297
+ wheelRFMesh.position.set(
298
+ wheelRFBody.position.x,
299
+ wheelRFBody.position.y,
300
+ wheelRFBody.position.z
301
+ )
302
+ wheelRFMesh.quaternion.set(
303
+ wheelRFBody.quaternion.x,
304
+ wheelRFBody.quaternion.y,
305
+ wheelRFBody.quaternion.z,
306
+ wheelRFBody.quaternion.w
307
+ )
308
+
309
+ wheelLBMesh.position.set(
310
+ wheelLBBody.position.x,
311
+ wheelLBBody.position.y,
312
+ wheelLBBody.position.z
313
+ )
314
+ wheelLBMesh.quaternion.set(
315
+ wheelLBBody.quaternion.x,
316
+ wheelLBBody.quaternion.y,
317
+ wheelLBBody.quaternion.z,
318
+ wheelLBBody.quaternion.w
319
+ )
320
+
321
+ wheelRBMesh.position.set(
322
+ wheelRBBody.position.x,
323
+ wheelRBBody.position.y,
324
+ wheelRBBody.position.z
325
+ )
326
+ wheelRBMesh.quaternion.set(
327
+ wheelRBBody.quaternion.x,
328
+ wheelRBBody.quaternion.y,
329
+ wheelRBBody.quaternion.z,
330
+ wheelRBBody.quaternion.w
331
+ )
332
+
333
+ thrusting = false
334
+ if (keyMap['KeyW'] || keyMap['ArrowUp']) {
335
+ if (forwardVelocity < 100.0) forwardVelocity += 1
336
+ thrusting = true
337
+ }
338
+ if (keyMap['KeyS'] || keyMap['ArrowDown']) {
339
+ if (forwardVelocity > -100.0) forwardVelocity -= 1
340
+ thrusting = true
341
+ }
342
+ if (keyMap['KeyA'] || keyMap['ArrowLeft']) {
343
+ if (rightVelocity > -1.0) rightVelocity -= 0.1
344
+ }
345
+ if (keyMap['KeyD'] || keyMap['ArrowRight']) {
346
+ if (rightVelocity < 1.0) rightVelocity += 0.1
347
+ }
348
+ if (keyMap['Space']) {
349
+ if (forwardVelocity > 0) {
350
+ forwardVelocity -= 1
351
+ }
352
+ if (forwardVelocity < 0) {
353
+ forwardVelocity += 1
354
+ }
355
+ }
356
+
357
+ if (!thrusting) {
358
+ //not going forward or backwards so gradually slow down
359
+ if (forwardVelocity > 0) {
360
+ forwardVelocity -= 0.25
361
+ }
362
+ if (forwardVelocity < 0) {
363
+ forwardVelocity += 0.25
364
+ }
365
+ }
366
+
367
+ constraintLB.setMotorSpeed(forwardVelocity)
368
+ constraintRB.setMotorSpeed(forwardVelocity)
369
+ constraintLF.axisA.z = rightVelocity
370
+ constraintRF.axisA.z = rightVelocity
371
+
372
+ camera.lookAt(carBodyMesh.position)
373
+
374
+ chaseCamPivot.getWorldPosition(v)
375
+ if (v.y < 1) {
376
+ v.y = 1
377
+ }
378
+ camera.position.lerpVectors(camera.position, v, 0.05)
379
+
380
+ render()
381
+
382
+ stats.update()
383
+ }
384
+
385
+ function render() {
386
+ renderer.render(scene, camera)
387
+ }
388
+
389
+ animate()