How to use custom method in Webdriverio

Best JavaScript code snippet using webdriverio-monorepo

MeshRenderer.js

Source:MeshRenderer.js Github

copy

Full Screen

1THREE.WebGLRenderer.MeshRenderer = function ( lowlevelrenderer, info ) {2 THREE.WebGLRenderer.Object3DRenderer.call( this, lowlevelrenderer, info );3};4THREE.WebGLRenderer.MeshRenderer.prototype = Object.create( THREE.WebGLRenderer.Object3DRenderer.prototype );5THREE.extend( THREE.WebGLRenderer.MeshRenderer.prototype, {6 createBuffers: function ( geometryGroup ) {7 var renderer = this.renderer;8 geometryGroup.__webglVertexBuffer = renderer.createBuffer();9 geometryGroup.__webglNormalBuffer = renderer.createBuffer();10 geometryGroup.__webglTangentBuffer = renderer.createBuffer();11 geometryGroup.__webglColorBuffer = renderer.createBuffer();12 geometryGroup.__webglUVBuffer = renderer.createBuffer();13 geometryGroup.__webglUV2Buffer = renderer.createBuffer();14 geometryGroup.__webglSkinIndicesBuffer = renderer.createBuffer();15 geometryGroup.__webglSkinWeightsBuffer = renderer.createBuffer();16 geometryGroup.__webglFaceBuffer = renderer.createBuffer();17 geometryGroup.__webglLineBuffer = renderer.createBuffer();18 var m, ml;19 if ( geometryGroup.numMorphTargets ) {20 geometryGroup.__webglMorphTargetsBuffers = [];21 for ( m = 0, ml = geometryGroup.numMorphTargets; m < ml; m ++ ) {22 geometryGroup.__webglMorphTargetsBuffers.push( renderer.createBuffer() );23 }24 }25 if ( geometryGroup.numMorphNormals ) {26 geometryGroup.__webglMorphNormalsBuffers = [];27 for ( m = 0, ml = geometryGroup.numMorphNormals; m < ml; m ++ ) {28 geometryGroup.__webglMorphNormalsBuffers.push( renderer.createBuffer() );29 }30 }31 this.info.memory.geometries ++;32 },33 initBuffers: function ( geometryGroup, object ) {34 var geometry = object.geometry,35 faces3 = geometryGroup.faces3,36 faces4 = geometryGroup.faces4,37 nvertices = faces3.length * 3 + faces4.length * 4,38 ntris = faces3.length * 1 + faces4.length * 2,39 nlines = faces3.length * 3 + faces4.length * 4,40 material = this.getBufferMaterial( object, geometryGroup ),41 uvType = this.bufferGuessUVType( material ),42 normalType = this.bufferGuessNormalType( material ),43 vertexColorType = this.bufferGuessVertexColorType( material );44 //console.log( "uvType", uvType, "normalType", normalType, "vertexColorType", vertexColorType, object, geometryGroup, material );45 geometryGroup.__vertexArray = new Float32Array( nvertices * 3 );46 if ( normalType ) {47 geometryGroup.__normalArray = new Float32Array( nvertices * 3 );48 }49 if ( geometry.hasTangents ) {50 geometryGroup.__tangentArray = new Float32Array( nvertices * 4 );51 }52 if ( vertexColorType ) {53 geometryGroup.__colorArray = new Float32Array( nvertices * 3 );54 }55 if ( uvType ) {56 if ( geometry.faceUvs.length > 0 || geometry.faceVertexUvs.length > 0 ) {57 geometryGroup.__uvArray = new Float32Array( nvertices * 2 );58 }59 if ( geometry.faceUvs.length > 1 || geometry.faceVertexUvs.length > 1 ) {60 geometryGroup.__uv2Array = new Float32Array( nvertices * 2 );61 }62 }63 if ( object.geometry.skinWeights.length && object.geometry.skinIndices.length ) {64 geometryGroup.__skinIndexArray = new Float32Array( nvertices * 4 );65 geometryGroup.__skinWeightArray = new Float32Array( nvertices * 4 );66 }67 geometryGroup.__faceArray = new Uint16Array( ntris * 3 );68 geometryGroup.__lineArray = new Uint16Array( nlines * 2 );69 var m, ml;70 if ( geometryGroup.numMorphTargets ) {71 geometryGroup.__morphTargetsArrays = [];72 for ( m = 0, ml = geometryGroup.numMorphTargets; m < ml; m ++ ) {73 geometryGroup.__morphTargetsArrays.push( new Float32Array( nvertices * 3 ) );74 }75 }76 if ( geometryGroup.numMorphNormals ) {77 geometryGroup.__morphNormalsArrays = [];78 for ( m = 0, ml = geometryGroup.numMorphNormals; m < ml; m ++ ) {79 geometryGroup.__morphNormalsArrays.push( new Float32Array( nvertices * 3 ) );80 }81 }82 geometryGroup.__webglFaceCount = ntris * 3;83 geometryGroup.__webglLineCount = nlines * 2;84 // custom attributes85 if ( material.attributes ) {86 if ( geometryGroup.__webglCustomAttributesList === undefined ) {87 geometryGroup.__webglCustomAttributesList = [];88 }89 for ( var a in material.attributes ) {90 // Do a shallow copy of the attribute object so different geometryGroup chunks use different91 // attribute buffers which are correctly indexed in the setMeshBuffers function92 var originalAttribute = material.attributes[ a ];93 var attribute = {};94 for ( var property in originalAttribute ) {95 attribute[ property ] = originalAttribute[ property ];96 }97 if ( !attribute.__webglInitialized || attribute.createUniqueBuffers ) {98 attribute.__webglInitialized = true;99 var size = 1; // "f" and "i"100 if( attribute.type === "v2" ) size = 2;101 else if( attribute.type === "v3" ) size = 3;102 else if( attribute.type === "v4" ) size = 4;103 else if( attribute.type === "c" ) size = 3;104 attribute.size = size;105 attribute.array = new Float32Array( nvertices * size );106 attribute.buffer = this.renderer.createBuffer();107 attribute.buffer.belongsToAttribute = a;108 originalAttribute.needsUpdate = true;109 attribute.__original = originalAttribute;110 }111 geometryGroup.__webglCustomAttributesList.push( attribute );112 }113 }114 geometryGroup.__inittedArrays = true;115 },116 setBuffers: function ( geometryGroup, object, dispose, material ) {117 if ( ! geometryGroup.__inittedArrays ) {118 return;119 }120 var renderer = this.renderer;121 var normalType = this.bufferGuessNormalType( material ),122 vertexColorType = this.bufferGuessVertexColorType( material ),123 uvType = this.bufferGuessUVType( material ),124 needsSmoothNormals = ( normalType === THREE.SmoothShading );125 var f, fl, fi, face,126 vertexNormals, faceNormal, normal,127 vertexColors, faceColor,128 vertexTangents,129 uv, uv2, v1, v2, v3, v4, t1, t2, t3, t4, n1, n2, n3, n4,130 c1, c2, c3, c4,131 sw1, sw2, sw3, sw4,132 si1, si2, si3, si4,133 sa1, sa2, sa3, sa4,134 sb1, sb2, sb3, sb4,135 m, ml, i, il,136 vn, uvi, uv2i,137 vk, vkl, vka,138 nka, chf, faceVertexNormals,139 a,140 vertexIndex = 0,141 offset = 0,142 offset_uv = 0,143 offset_uv2 = 0,144 offset_face = 0,145 offset_normal = 0,146 offset_tangent = 0,147 offset_line = 0,148 offset_color = 0,149 offset_skin = 0,150 offset_morphTarget = 0,151 offset_custom = 0,152 offset_customSrc = 0,153 value,154 vertexArray = geometryGroup.__vertexArray,155 uvArray = geometryGroup.__uvArray,156 uv2Array = geometryGroup.__uv2Array,157 normalArray = geometryGroup.__normalArray,158 tangentArray = geometryGroup.__tangentArray,159 colorArray = geometryGroup.__colorArray,160 skinIndexArray = geometryGroup.__skinIndexArray,161 skinWeightArray = geometryGroup.__skinWeightArray,162 morphTargetsArrays = geometryGroup.__morphTargetsArrays,163 morphNormalsArrays = geometryGroup.__morphNormalsArrays,164 customAttributes = geometryGroup.__webglCustomAttributesList,165 customAttribute,166 faceArray = geometryGroup.__faceArray,167 lineArray = geometryGroup.__lineArray,168 geometry = object.geometry, // this is shared for all chunks169 dirtyVertices = geometry.verticesNeedUpdate,170 dirtyElements = geometry.elementsNeedUpdate,171 dirtyUvs = geometry.uvsNeedUpdate,172 dirtyNormals = geometry.normalsNeedUpdate,173 dirtyTangents = geometry.tangentsNeedUpdate,174 dirtyColors = geometry.colorsNeedUpdate,175 dirtyMorphTargets = geometry.morphTargetsNeedUpdate,176 vertices = geometry.vertices,177 chunk_faces3 = geometryGroup.faces3,178 chunk_faces4 = geometryGroup.faces4,179 obj_faces = geometry.faces,180 obj_uvs = geometry.faceVertexUvs[ 0 ],181 obj_uvs2 = geometry.faceVertexUvs[ 1 ],182 obj_colors = geometry.colors,183 obj_skinIndices = geometry.skinIndices,184 obj_skinWeights = geometry.skinWeights,185 morphTargets = geometry.morphTargets,186 morphNormals = geometry.morphNormals;187 if ( dirtyVertices ) {188 for ( f = 0, fl = chunk_faces3.length; f < fl; f ++ ) {189 face = obj_faces[ chunk_faces3[ f ] ];190 v1 = vertices[ face.a ];191 v2 = vertices[ face.b ];192 v3 = vertices[ face.c ];193 vertexArray[ offset ] = v1.x;194 vertexArray[ offset + 1 ] = v1.y;195 vertexArray[ offset + 2 ] = v1.z;196 vertexArray[ offset + 3 ] = v2.x;197 vertexArray[ offset + 4 ] = v2.y;198 vertexArray[ offset + 5 ] = v2.z;199 vertexArray[ offset + 6 ] = v3.x;200 vertexArray[ offset + 7 ] = v3.y;201 vertexArray[ offset + 8 ] = v3.z;202 offset += 9;203 }204 for ( f = 0, fl = chunk_faces4.length; f < fl; f ++ ) {205 face = obj_faces[ chunk_faces4[ f ] ];206 v1 = vertices[ face.a ];207 v2 = vertices[ face.b ];208 v3 = vertices[ face.c ];209 v4 = vertices[ face.d ];210 vertexArray[ offset ] = v1.x;211 vertexArray[ offset + 1 ] = v1.y;212 vertexArray[ offset + 2 ] = v1.z;213 vertexArray[ offset + 3 ] = v2.x;214 vertexArray[ offset + 4 ] = v2.y;215 vertexArray[ offset + 5 ] = v2.z;216 vertexArray[ offset + 6 ] = v3.x;217 vertexArray[ offset + 7 ] = v3.y;218 vertexArray[ offset + 8 ] = v3.z;219 vertexArray[ offset + 9 ] = v4.x;220 vertexArray[ offset + 10 ] = v4.y;221 vertexArray[ offset + 11 ] = v4.z;222 offset += 12;223 }224 renderer.setDynamicArrayBuffer( geometryGroup.__webglVertexBuffer, vertexArray);225 }226 if ( dirtyMorphTargets ) {227 for ( vk = 0, vkl = morphTargets.length; vk < vkl; vk ++ ) {228 offset_morphTarget = 0;229 for ( f = 0, fl = chunk_faces3.length; f < fl; f ++ ) {230 chf = chunk_faces3[ f ];231 face = obj_faces[ chf ];232 // morph positions233 v1 = morphTargets[ vk ].vertices[ face.a ];234 v2 = morphTargets[ vk ].vertices[ face.b ];235 v3 = morphTargets[ vk ].vertices[ face.c ];236 vka = morphTargetsArrays[ vk ];237 vka[ offset_morphTarget ] = v1.x;238 vka[ offset_morphTarget + 1 ] = v1.y;239 vka[ offset_morphTarget + 2 ] = v1.z;240 vka[ offset_morphTarget + 3 ] = v2.x;241 vka[ offset_morphTarget + 4 ] = v2.y;242 vka[ offset_morphTarget + 5 ] = v2.z;243 vka[ offset_morphTarget + 6 ] = v3.x;244 vka[ offset_morphTarget + 7 ] = v3.y;245 vka[ offset_morphTarget + 8 ] = v3.z;246 // morph normals247 if ( material.morphNormals ) {248 if ( needsSmoothNormals ) {249 faceVertexNormals = morphNormals[ vk ].vertexNormals[ chf ];250 n1 = faceVertexNormals.a;251 n2 = faceVertexNormals.b;252 n3 = faceVertexNormals.c;253 } else {254 n1 = morphNormals[ vk ].faceNormals[ chf ];255 n2 = n1;256 n3 = n1;257 }258 nka = morphNormalsArrays[ vk ];259 nka[ offset_morphTarget ] = n1.x;260 nka[ offset_morphTarget + 1 ] = n1.y;261 nka[ offset_morphTarget + 2 ] = n1.z;262 nka[ offset_morphTarget + 3 ] = n2.x;263 nka[ offset_morphTarget + 4 ] = n2.y;264 nka[ offset_morphTarget + 5 ] = n2.z;265 nka[ offset_morphTarget + 6 ] = n3.x;266 nka[ offset_morphTarget + 7 ] = n3.y;267 nka[ offset_morphTarget + 8 ] = n3.z;268 }269 //270 offset_morphTarget += 9;271 }272 for ( f = 0, fl = chunk_faces4.length; f < fl; f ++ ) {273 chf = chunk_faces4[ f ];274 face = obj_faces[ chf ];275 // morph positions276 v1 = morphTargets[ vk ].vertices[ face.a ];277 v2 = morphTargets[ vk ].vertices[ face.b ];278 v3 = morphTargets[ vk ].vertices[ face.c ];279 v4 = morphTargets[ vk ].vertices[ face.d ];280 vka = morphTargetsArrays[ vk ];281 vka[ offset_morphTarget ] = v1.x;282 vka[ offset_morphTarget + 1 ] = v1.y;283 vka[ offset_morphTarget + 2 ] = v1.z;284 vka[ offset_morphTarget + 3 ] = v2.x;285 vka[ offset_morphTarget + 4 ] = v2.y;286 vka[ offset_morphTarget + 5 ] = v2.z;287 vka[ offset_morphTarget + 6 ] = v3.x;288 vka[ offset_morphTarget + 7 ] = v3.y;289 vka[ offset_morphTarget + 8 ] = v3.z;290 vka[ offset_morphTarget + 9 ] = v4.x;291 vka[ offset_morphTarget + 10 ] = v4.y;292 vka[ offset_morphTarget + 11 ] = v4.z;293 // morph normals294 if ( material.morphNormals ) {295 if ( needsSmoothNormals ) {296 faceVertexNormals = morphNormals[ vk ].vertexNormals[ chf ];297 n1 = faceVertexNormals.a;298 n2 = faceVertexNormals.b;299 n3 = faceVertexNormals.c;300 n4 = faceVertexNormals.d;301 } else {302 n1 = morphNormals[ vk ].faceNormals[ chf ];303 n2 = n1;304 n3 = n1;305 n4 = n1;306 }307 nka = morphNormalsArrays[ vk ];308 nka[ offset_morphTarget ] = n1.x;309 nka[ offset_morphTarget + 1 ] = n1.y;310 nka[ offset_morphTarget + 2 ] = n1.z;311 nka[ offset_morphTarget + 3 ] = n2.x;312 nka[ offset_morphTarget + 4 ] = n2.y;313 nka[ offset_morphTarget + 5 ] = n2.z;314 nka[ offset_morphTarget + 6 ] = n3.x;315 nka[ offset_morphTarget + 7 ] = n3.y;316 nka[ offset_morphTarget + 8 ] = n3.z;317 nka[ offset_morphTarget + 9 ] = n4.x;318 nka[ offset_morphTarget + 10 ] = n4.y;319 nka[ offset_morphTarget + 11 ] = n4.z;320 }321 //322 offset_morphTarget += 12;323 }324 this.renderer.setDynamicArrayBuffer( geometryGroup.__webglMorphTargetsBuffers[ vk ], morphTargetsArrays[ vk ]);325 if ( material.morphNormals ) {326 this.renderer.setDynamicArrayBuffer( geometryGroup.__webglMorphNormalsBuffers[ vk ], morphNormalsArrays[ vk ]);327 }328 }329 }330 if ( obj_skinWeights.length ) {331 for ( f = 0, fl = chunk_faces3.length; f < fl; f ++ ) {332 face = obj_faces[ chunk_faces3[ f ] ];333 // weights334 sw1 = obj_skinWeights[ face.a ];335 sw2 = obj_skinWeights[ face.b ];336 sw3 = obj_skinWeights[ face.c ];337 skinWeightArray[ offset_skin ] = sw1.x;338 skinWeightArray[ offset_skin + 1 ] = sw1.y;339 skinWeightArray[ offset_skin + 2 ] = sw1.z;340 skinWeightArray[ offset_skin + 3 ] = sw1.w;341 skinWeightArray[ offset_skin + 4 ] = sw2.x;342 skinWeightArray[ offset_skin + 5 ] = sw2.y;343 skinWeightArray[ offset_skin + 6 ] = sw2.z;344 skinWeightArray[ offset_skin + 7 ] = sw2.w;345 skinWeightArray[ offset_skin + 8 ] = sw3.x;346 skinWeightArray[ offset_skin + 9 ] = sw3.y;347 skinWeightArray[ offset_skin + 10 ] = sw3.z;348 skinWeightArray[ offset_skin + 11 ] = sw3.w;349 // indices350 si1 = obj_skinIndices[ face.a ];351 si2 = obj_skinIndices[ face.b ];352 si3 = obj_skinIndices[ face.c ];353 skinIndexArray[ offset_skin ] = si1.x;354 skinIndexArray[ offset_skin + 1 ] = si1.y;355 skinIndexArray[ offset_skin + 2 ] = si1.z;356 skinIndexArray[ offset_skin + 3 ] = si1.w;357 skinIndexArray[ offset_skin + 4 ] = si2.x;358 skinIndexArray[ offset_skin + 5 ] = si2.y;359 skinIndexArray[ offset_skin + 6 ] = si2.z;360 skinIndexArray[ offset_skin + 7 ] = si2.w;361 skinIndexArray[ offset_skin + 8 ] = si3.x;362 skinIndexArray[ offset_skin + 9 ] = si3.y;363 skinIndexArray[ offset_skin + 10 ] = si3.z;364 skinIndexArray[ offset_skin + 11 ] = si3.w;365 offset_skin += 12;366 }367 for ( f = 0, fl = chunk_faces4.length; f < fl; f ++ ) {368 face = obj_faces[ chunk_faces4[ f ] ];369 // weights370 sw1 = obj_skinWeights[ face.a ];371 sw2 = obj_skinWeights[ face.b ];372 sw3 = obj_skinWeights[ face.c ];373 sw4 = obj_skinWeights[ face.d ];374 skinWeightArray[ offset_skin ] = sw1.x;375 skinWeightArray[ offset_skin + 1 ] = sw1.y;376 skinWeightArray[ offset_skin + 2 ] = sw1.z;377 skinWeightArray[ offset_skin + 3 ] = sw1.w;378 skinWeightArray[ offset_skin + 4 ] = sw2.x;379 skinWeightArray[ offset_skin + 5 ] = sw2.y;380 skinWeightArray[ offset_skin + 6 ] = sw2.z;381 skinWeightArray[ offset_skin + 7 ] = sw2.w;382 skinWeightArray[ offset_skin + 8 ] = sw3.x;383 skinWeightArray[ offset_skin + 9 ] = sw3.y;384 skinWeightArray[ offset_skin + 10 ] = sw3.z;385 skinWeightArray[ offset_skin + 11 ] = sw3.w;386 skinWeightArray[ offset_skin + 12 ] = sw4.x;387 skinWeightArray[ offset_skin + 13 ] = sw4.y;388 skinWeightArray[ offset_skin + 14 ] = sw4.z;389 skinWeightArray[ offset_skin + 15 ] = sw4.w;390 // indices391 si1 = obj_skinIndices[ face.a ];392 si2 = obj_skinIndices[ face.b ];393 si3 = obj_skinIndices[ face.c ];394 si4 = obj_skinIndices[ face.d ];395 skinIndexArray[ offset_skin ] = si1.x;396 skinIndexArray[ offset_skin + 1 ] = si1.y;397 skinIndexArray[ offset_skin + 2 ] = si1.z;398 skinIndexArray[ offset_skin + 3 ] = si1.w;399 skinIndexArray[ offset_skin + 4 ] = si2.x;400 skinIndexArray[ offset_skin + 5 ] = si2.y;401 skinIndexArray[ offset_skin + 6 ] = si2.z;402 skinIndexArray[ offset_skin + 7 ] = si2.w;403 skinIndexArray[ offset_skin + 8 ] = si3.x;404 skinIndexArray[ offset_skin + 9 ] = si3.y;405 skinIndexArray[ offset_skin + 10 ] = si3.z;406 skinIndexArray[ offset_skin + 11 ] = si3.w;407 skinIndexArray[ offset_skin + 12 ] = si4.x;408 skinIndexArray[ offset_skin + 13 ] = si4.y;409 skinIndexArray[ offset_skin + 14 ] = si4.z;410 skinIndexArray[ offset_skin + 15 ] = si4.w;411 offset_skin += 16;412 }413 if ( offset_skin > 0 ) {414 renderer.setDynamicArrayBuffer( geometryGroup.__webglSkinIndicesBuffer, skinIndexArray);415 renderer.setDynamicArrayBuffer( geometryGroup.__webglSkinWeightsBuffer, skinWeightArray);416 }417 }418 if ( dirtyColors && vertexColorType ) {419 for ( f = 0, fl = chunk_faces3.length; f < fl; f ++ ) {420 face = obj_faces[ chunk_faces3[ f ] ];421 vertexColors = face.vertexColors;422 faceColor = face.color;423 if ( vertexColors.length === 3 && vertexColorType === THREE.VertexColors ) {424 c1 = vertexColors[ 0 ];425 c2 = vertexColors[ 1 ];426 c3 = vertexColors[ 2 ];427 } else {428 c1 = faceColor;429 c2 = faceColor;430 c3 = faceColor;431 }432 colorArray[ offset_color ] = c1.r;433 colorArray[ offset_color + 1 ] = c1.g;434 colorArray[ offset_color + 2 ] = c1.b;435 colorArray[ offset_color + 3 ] = c2.r;436 colorArray[ offset_color + 4 ] = c2.g;437 colorArray[ offset_color + 5 ] = c2.b;438 colorArray[ offset_color + 6 ] = c3.r;439 colorArray[ offset_color + 7 ] = c3.g;440 colorArray[ offset_color + 8 ] = c3.b;441 offset_color += 9;442 }443 for ( f = 0, fl = chunk_faces4.length; f < fl; f ++ ) {444 face = obj_faces[ chunk_faces4[ f ] ];445 vertexColors = face.vertexColors;446 faceColor = face.color;447 if ( vertexColors.length === 4 && vertexColorType === THREE.VertexColors ) {448 c1 = vertexColors[ 0 ];449 c2 = vertexColors[ 1 ];450 c3 = vertexColors[ 2 ];451 c4 = vertexColors[ 3 ];452 } else {453 c1 = faceColor;454 c2 = faceColor;455 c3 = faceColor;456 c4 = faceColor;457 }458 colorArray[ offset_color ] = c1.r;459 colorArray[ offset_color + 1 ] = c1.g;460 colorArray[ offset_color + 2 ] = c1.b;461 colorArray[ offset_color + 3 ] = c2.r;462 colorArray[ offset_color + 4 ] = c2.g;463 colorArray[ offset_color + 5 ] = c2.b;464 colorArray[ offset_color + 6 ] = c3.r;465 colorArray[ offset_color + 7 ] = c3.g;466 colorArray[ offset_color + 8 ] = c3.b;467 colorArray[ offset_color + 9 ] = c4.r;468 colorArray[ offset_color + 10 ] = c4.g;469 colorArray[ offset_color + 11 ] = c4.b;470 offset_color += 12;471 }472 if ( offset_color > 0 ) {473 renderer.setDynamicArrayBuffer( geometryGroup.__webglColorBuffer, colorArray);474 }475 }476 if ( dirtyTangents && geometry.hasTangents ) {477 for ( f = 0, fl = chunk_faces3.length; f < fl; f ++ ) {478 face = obj_faces[ chunk_faces3[ f ] ];479 vertexTangents = face.vertexTangents;480 t1 = vertexTangents[ 0 ];481 t2 = vertexTangents[ 1 ];482 t3 = vertexTangents[ 2 ];483 tangentArray[ offset_tangent ] = t1.x;484 tangentArray[ offset_tangent + 1 ] = t1.y;485 tangentArray[ offset_tangent + 2 ] = t1.z;486 tangentArray[ offset_tangent + 3 ] = t1.w;487 tangentArray[ offset_tangent + 4 ] = t2.x;488 tangentArray[ offset_tangent + 5 ] = t2.y;489 tangentArray[ offset_tangent + 6 ] = t2.z;490 tangentArray[ offset_tangent + 7 ] = t2.w;491 tangentArray[ offset_tangent + 8 ] = t3.x;492 tangentArray[ offset_tangent + 9 ] = t3.y;493 tangentArray[ offset_tangent + 10 ] = t3.z;494 tangentArray[ offset_tangent + 11 ] = t3.w;495 offset_tangent += 12;496 }497 for ( f = 0, fl = chunk_faces4.length; f < fl; f ++ ) {498 face = obj_faces[ chunk_faces4[ f ] ];499 vertexTangents = face.vertexTangents;500 t1 = vertexTangents[ 0 ];501 t2 = vertexTangents[ 1 ];502 t3 = vertexTangents[ 2 ];503 t4 = vertexTangents[ 3 ];504 tangentArray[ offset_tangent ] = t1.x;505 tangentArray[ offset_tangent + 1 ] = t1.y;506 tangentArray[ offset_tangent + 2 ] = t1.z;507 tangentArray[ offset_tangent + 3 ] = t1.w;508 tangentArray[ offset_tangent + 4 ] = t2.x;509 tangentArray[ offset_tangent + 5 ] = t2.y;510 tangentArray[ offset_tangent + 6 ] = t2.z;511 tangentArray[ offset_tangent + 7 ] = t2.w;512 tangentArray[ offset_tangent + 8 ] = t3.x;513 tangentArray[ offset_tangent + 9 ] = t3.y;514 tangentArray[ offset_tangent + 10 ] = t3.z;515 tangentArray[ offset_tangent + 11 ] = t3.w;516 tangentArray[ offset_tangent + 12 ] = t4.x;517 tangentArray[ offset_tangent + 13 ] = t4.y;518 tangentArray[ offset_tangent + 14 ] = t4.z;519 tangentArray[ offset_tangent + 15 ] = t4.w;520 offset_tangent += 16;521 }522 renderer.setDynamicArrayBuffer( geometryGroup.__webglTangentBuffer, tangentArray);523 }524 if ( dirtyNormals && normalType ) {525 for ( f = 0, fl = chunk_faces3.length; f < fl; f ++ ) {526 face = obj_faces[ chunk_faces3[ f ] ];527 vertexNormals = face.vertexNormals;528 faceNormal = face.normal;529 if ( vertexNormals.length === 3 && needsSmoothNormals ) {530 for ( i = 0; i < 3; i ++ ) {531 vn = vertexNormals[ i ];532 normalArray[ offset_normal ] = vn.x;533 normalArray[ offset_normal + 1 ] = vn.y;534 normalArray[ offset_normal + 2 ] = vn.z;535 offset_normal += 3;536 }537 } else {538 for ( i = 0; i < 3; i ++ ) {539 normalArray[ offset_normal ] = faceNormal.x;540 normalArray[ offset_normal + 1 ] = faceNormal.y;541 normalArray[ offset_normal + 2 ] = faceNormal.z;542 offset_normal += 3;543 }544 }545 }546 for ( f = 0, fl = chunk_faces4.length; f < fl; f ++ ) {547 face = obj_faces[ chunk_faces4[ f ] ];548 vertexNormals = face.vertexNormals;549 faceNormal = face.normal;550 if ( vertexNormals.length === 4 && needsSmoothNormals ) {551 for ( i = 0; i < 4; i ++ ) {552 vn = vertexNormals[ i ];553 normalArray[ offset_normal ] = vn.x;554 normalArray[ offset_normal + 1 ] = vn.y;555 normalArray[ offset_normal + 2 ] = vn.z;556 offset_normal += 3;557 }558 } else {559 for ( i = 0; i < 4; i ++ ) {560 normalArray[ offset_normal ] = faceNormal.x;561 normalArray[ offset_normal + 1 ] = faceNormal.y;562 normalArray[ offset_normal + 2 ] = faceNormal.z;563 offset_normal += 3;564 }565 }566 }567 renderer.setDynamicArrayBuffer( geometryGroup.__webglNormalBuffer, normalArray);568 }569 if ( dirtyUvs && obj_uvs && uvType ) {570 for ( f = 0, fl = chunk_faces3.length; f < fl; f ++ ) {571 fi = chunk_faces3[ f ];572 uv = obj_uvs[ fi ];573 if ( uv === undefined ) continue;574 for ( i = 0; i < 3; i ++ ) {575 uvi = uv[ i ];576 uvArray[ offset_uv ] = uvi.x;577 uvArray[ offset_uv + 1 ] = uvi.y;578 offset_uv += 2;579 }580 }581 for ( f = 0, fl = chunk_faces4.length; f < fl; f ++ ) {582 fi = chunk_faces4[ f ];583 uv = obj_uvs[ fi ];584 if ( uv === undefined ) continue;585 for ( i = 0; i < 4; i ++ ) {586 uvi = uv[ i ];587 uvArray[ offset_uv ] = uvi.x;588 uvArray[ offset_uv + 1 ] = uvi.y;589 offset_uv += 2;590 }591 }592 if ( offset_uv > 0 ) {593 renderer.setDynamicArrayBuffer( geometryGroup.__webglUVBuffer, uvArray);594 }595 }596 if ( dirtyUvs && obj_uvs2 && uvType ) {597 for ( f = 0, fl = chunk_faces3.length; f < fl; f ++ ) {598 fi = chunk_faces3[ f ];599 uv2 = obj_uvs2[ fi ];600 if ( uv2 === undefined ) continue;601 for ( i = 0; i < 3; i ++ ) {602 uv2i = uv2[ i ];603 uv2Array[ offset_uv2 ] = uv2i.x;604 uv2Array[ offset_uv2 + 1 ] = uv2i.y;605 offset_uv2 += 2;606 }607 }608 for ( f = 0, fl = chunk_faces4.length; f < fl; f ++ ) {609 fi = chunk_faces4[ f ];610 uv2 = obj_uvs2[ fi ];611 if ( uv2 === undefined ) continue;612 for ( i = 0; i < 4; i ++ ) {613 uv2i = uv2[ i ];614 uv2Array[ offset_uv2 ] = uv2i.x;615 uv2Array[ offset_uv2 + 1 ] = uv2i.y;616 offset_uv2 += 2;617 }618 }619 if ( offset_uv2 > 0 ) {620 renderer.setDynamicArrayBuffer( geometryGroup.__webglUV2Buffer, uv2Array);621 }622 }623 if ( dirtyElements ) {624 for ( f = 0, fl = chunk_faces3.length; f < fl; f ++ ) {625 faceArray[ offset_face ] = vertexIndex;626 faceArray[ offset_face + 1 ] = vertexIndex + 1;627 faceArray[ offset_face + 2 ] = vertexIndex + 2;628 offset_face += 3;629 lineArray[ offset_line ] = vertexIndex;630 lineArray[ offset_line + 1 ] = vertexIndex + 1;631 lineArray[ offset_line + 2 ] = vertexIndex;632 lineArray[ offset_line + 3 ] = vertexIndex + 2;633 lineArray[ offset_line + 4 ] = vertexIndex + 1;634 lineArray[ offset_line + 5 ] = vertexIndex + 2;635 offset_line += 6;636 vertexIndex += 3;637 }638 for ( f = 0, fl = chunk_faces4.length; f < fl; f ++ ) {639 faceArray[ offset_face ] = vertexIndex;640 faceArray[ offset_face + 1 ] = vertexIndex + 1;641 faceArray[ offset_face + 2 ] = vertexIndex + 3;642 faceArray[ offset_face + 3 ] = vertexIndex + 1;643 faceArray[ offset_face + 4 ] = vertexIndex + 2;644 faceArray[ offset_face + 5 ] = vertexIndex + 3;645 offset_face += 6;646 lineArray[ offset_line ] = vertexIndex;647 lineArray[ offset_line + 1 ] = vertexIndex + 1;648 lineArray[ offset_line + 2 ] = vertexIndex;649 lineArray[ offset_line + 3 ] = vertexIndex + 3;650 lineArray[ offset_line + 4 ] = vertexIndex + 1;651 lineArray[ offset_line + 5 ] = vertexIndex + 2;652 lineArray[ offset_line + 6 ] = vertexIndex + 2;653 lineArray[ offset_line + 7 ] = vertexIndex + 3;654 offset_line += 8;655 vertexIndex += 4;656 }657 renderer.setDynamicIndexBuffer( geometryGroup.__webglFaceBuffer, faceArray);658 renderer.setDynamicIndexBuffer( geometryGroup.__webglLineBuffer, lineArray);659 }660 if ( customAttributes ) {661 for ( i = 0, il = customAttributes.length; i < il; i ++ ) {662 customAttribute = customAttributes[ i ];663 if ( ! customAttribute.__original.needsUpdate ) continue;664 offset_custom = 0;665 offset_customSrc = 0;666 if ( customAttribute.size === 1 ) {667 if ( customAttribute.boundTo === undefined || customAttribute.boundTo === "vertices" ) {668 for ( f = 0, fl = chunk_faces3.length; f < fl; f ++ ) {669 face = obj_faces[ chunk_faces3[ f ] ];670 customAttribute.array[ offset_custom ] = customAttribute.value[ face.a ];671 customAttribute.array[ offset_custom + 1 ] = customAttribute.value[ face.b ];672 customAttribute.array[ offset_custom + 2 ] = customAttribute.value[ face.c ];673 offset_custom += 3;674 }675 for ( f = 0, fl = chunk_faces4.length; f < fl; f ++ ) {676 face = obj_faces[ chunk_faces4[ f ] ];677 customAttribute.array[ offset_custom ] = customAttribute.value[ face.a ];678 customAttribute.array[ offset_custom + 1 ] = customAttribute.value[ face.b ];679 customAttribute.array[ offset_custom + 2 ] = customAttribute.value[ face.c ];680 customAttribute.array[ offset_custom + 3 ] = customAttribute.value[ face.d ];681 offset_custom += 4;682 }683 } else if ( customAttribute.boundTo === "faces" ) {684 for ( f = 0, fl = chunk_faces3.length; f < fl; f ++ ) {685 value = customAttribute.value[ chunk_faces3[ f ] ];686 customAttribute.array[ offset_custom ] = value;687 customAttribute.array[ offset_custom + 1 ] = value;688 customAttribute.array[ offset_custom + 2 ] = value;689 offset_custom += 3;690 }691 for ( f = 0, fl = chunk_faces4.length; f < fl; f ++ ) {692 value = customAttribute.value[ chunk_faces4[ f ] ];693 customAttribute.array[ offset_custom ] = value;694 customAttribute.array[ offset_custom + 1 ] = value;695 customAttribute.array[ offset_custom + 2 ] = value;696 customAttribute.array[ offset_custom + 3 ] = value;697 offset_custom += 4;698 }699 }700 } else if ( customAttribute.size === 2 ) {701 if ( customAttribute.boundTo === undefined || customAttribute.boundTo === "vertices" ) {702 for ( f = 0, fl = chunk_faces3.length; f < fl; f ++ ) {703 face = obj_faces[ chunk_faces3[ f ] ];704 v1 = customAttribute.value[ face.a ];705 v2 = customAttribute.value[ face.b ];706 v3 = customAttribute.value[ face.c ];707 customAttribute.array[ offset_custom ] = v1.x;708 customAttribute.array[ offset_custom + 1 ] = v1.y;709 customAttribute.array[ offset_custom + 2 ] = v2.x;710 customAttribute.array[ offset_custom + 3 ] = v2.y;711 customAttribute.array[ offset_custom + 4 ] = v3.x;712 customAttribute.array[ offset_custom + 5 ] = v3.y;713 offset_custom += 6;714 }715 for ( f = 0, fl = chunk_faces4.length; f < fl; f ++ ) {716 face = obj_faces[ chunk_faces4[ f ] ];717 v1 = customAttribute.value[ face.a ];718 v2 = customAttribute.value[ face.b ];719 v3 = customAttribute.value[ face.c ];720 v4 = customAttribute.value[ face.d ];721 customAttribute.array[ offset_custom ] = v1.x;722 customAttribute.array[ offset_custom + 1 ] = v1.y;723 customAttribute.array[ offset_custom + 2 ] = v2.x;724 customAttribute.array[ offset_custom + 3 ] = v2.y;725 customAttribute.array[ offset_custom + 4 ] = v3.x;726 customAttribute.array[ offset_custom + 5 ] = v3.y;727 customAttribute.array[ offset_custom + 6 ] = v4.x;728 customAttribute.array[ offset_custom + 7 ] = v4.y;729 offset_custom += 8;730 }731 } else if ( customAttribute.boundTo === "faces" ) {732 for ( f = 0, fl = chunk_faces3.length; f < fl; f ++ ) {733 value = customAttribute.value[ chunk_faces3[ f ] ];734 v1 = value;735 v2 = value;736 v3 = value;737 customAttribute.array[ offset_custom ] = v1.x;738 customAttribute.array[ offset_custom + 1 ] = v1.y;739 customAttribute.array[ offset_custom + 2 ] = v2.x;740 customAttribute.array[ offset_custom + 3 ] = v2.y;741 customAttribute.array[ offset_custom + 4 ] = v3.x;742 customAttribute.array[ offset_custom + 5 ] = v3.y;743 offset_custom += 6;744 }745 for ( f = 0, fl = chunk_faces4.length; f < fl; f ++ ) {746 value = customAttribute.value[ chunk_faces4[ f ] ];747 v1 = value;748 v2 = value;749 v3 = value;750 v4 = value;751 customAttribute.array[ offset_custom ] = v1.x;752 customAttribute.array[ offset_custom + 1 ] = v1.y;753 customAttribute.array[ offset_custom + 2 ] = v2.x;754 customAttribute.array[ offset_custom + 3 ] = v2.y;755 customAttribute.array[ offset_custom + 4 ] = v3.x;756 customAttribute.array[ offset_custom + 5 ] = v3.y;757 customAttribute.array[ offset_custom + 6 ] = v4.x;758 customAttribute.array[ offset_custom + 7 ] = v4.y;759 offset_custom += 8;760 }761 }762 } else if ( customAttribute.size === 3 ) {763 var pp;764 if ( customAttribute.type === "c" ) {765 pp = [ "r", "g", "b" ];766 } else {767 pp = [ "x", "y", "z" ];768 }769 if ( customAttribute.boundTo === undefined || customAttribute.boundTo === "vertices" ) {770 for ( f = 0, fl = chunk_faces3.length; f < fl; f ++ ) {771 face = obj_faces[ chunk_faces3[ f ] ];772 v1 = customAttribute.value[ face.a ];773 v2 = customAttribute.value[ face.b ];774 v3 = customAttribute.value[ face.c ];775 customAttribute.array[ offset_custom ] = v1[ pp[ 0 ] ];776 customAttribute.array[ offset_custom + 1 ] = v1[ pp[ 1 ] ];777 customAttribute.array[ offset_custom + 2 ] = v1[ pp[ 2 ] ];778 customAttribute.array[ offset_custom + 3 ] = v2[ pp[ 0 ] ];779 customAttribute.array[ offset_custom + 4 ] = v2[ pp[ 1 ] ];780 customAttribute.array[ offset_custom + 5 ] = v2[ pp[ 2 ] ];781 customAttribute.array[ offset_custom + 6 ] = v3[ pp[ 0 ] ];782 customAttribute.array[ offset_custom + 7 ] = v3[ pp[ 1 ] ];783 customAttribute.array[ offset_custom + 8 ] = v3[ pp[ 2 ] ];784 offset_custom += 9;785 }786 for ( f = 0, fl = chunk_faces4.length; f < fl; f ++ ) {787 face = obj_faces[ chunk_faces4[ f ] ];788 v1 = customAttribute.value[ face.a ];789 v2 = customAttribute.value[ face.b ];790 v3 = customAttribute.value[ face.c ];791 v4 = customAttribute.value[ face.d ];792 customAttribute.array[ offset_custom ] = v1[ pp[ 0 ] ];793 customAttribute.array[ offset_custom + 1 ] = v1[ pp[ 1 ] ];794 customAttribute.array[ offset_custom + 2 ] = v1[ pp[ 2 ] ];795 customAttribute.array[ offset_custom + 3 ] = v2[ pp[ 0 ] ];796 customAttribute.array[ offset_custom + 4 ] = v2[ pp[ 1 ] ];797 customAttribute.array[ offset_custom + 5 ] = v2[ pp[ 2 ] ];798 customAttribute.array[ offset_custom + 6 ] = v3[ pp[ 0 ] ];799 customAttribute.array[ offset_custom + 7 ] = v3[ pp[ 1 ] ];800 customAttribute.array[ offset_custom + 8 ] = v3[ pp[ 2 ] ];801 customAttribute.array[ offset_custom + 9 ] = v4[ pp[ 0 ] ];802 customAttribute.array[ offset_custom + 10 ] = v4[ pp[ 1 ] ];803 customAttribute.array[ offset_custom + 11 ] = v4[ pp[ 2 ] ];804 offset_custom += 12;805 }806 } else if ( customAttribute.boundTo === "faces" ) {807 for ( f = 0, fl = chunk_faces3.length; f < fl; f ++ ) {808 value = customAttribute.value[ chunk_faces3[ f ] ];809 v1 = value;810 v2 = value;811 v3 = value;812 customAttribute.array[ offset_custom ] = v1[ pp[ 0 ] ];813 customAttribute.array[ offset_custom + 1 ] = v1[ pp[ 1 ] ];814 customAttribute.array[ offset_custom + 2 ] = v1[ pp[ 2 ] ];815 customAttribute.array[ offset_custom + 3 ] = v2[ pp[ 0 ] ];816 customAttribute.array[ offset_custom + 4 ] = v2[ pp[ 1 ] ];817 customAttribute.array[ offset_custom + 5 ] = v2[ pp[ 2 ] ];818 customAttribute.array[ offset_custom + 6 ] = v3[ pp[ 0 ] ];819 customAttribute.array[ offset_custom + 7 ] = v3[ pp[ 1 ] ];820 customAttribute.array[ offset_custom + 8 ] = v3[ pp[ 2 ] ];821 offset_custom += 9;822 }823 for ( f = 0, fl = chunk_faces4.length; f < fl; f ++ ) {824 value = customAttribute.value[ chunk_faces4[ f ] ];825 v1 = value;826 v2 = value;827 v3 = value;828 v4 = value;829 customAttribute.array[ offset_custom ] = v1[ pp[ 0 ] ];830 customAttribute.array[ offset_custom + 1 ] = v1[ pp[ 1 ] ];831 customAttribute.array[ offset_custom + 2 ] = v1[ pp[ 2 ] ];832 customAttribute.array[ offset_custom + 3 ] = v2[ pp[ 0 ] ];833 customAttribute.array[ offset_custom + 4 ] = v2[ pp[ 1 ] ];834 customAttribute.array[ offset_custom + 5 ] = v2[ pp[ 2 ] ];835 customAttribute.array[ offset_custom + 6 ] = v3[ pp[ 0 ] ];836 customAttribute.array[ offset_custom + 7 ] = v3[ pp[ 1 ] ];837 customAttribute.array[ offset_custom + 8 ] = v3[ pp[ 2 ] ];838 customAttribute.array[ offset_custom + 9 ] = v4[ pp[ 0 ] ];839 customAttribute.array[ offset_custom + 10 ] = v4[ pp[ 1 ] ];840 customAttribute.array[ offset_custom + 11 ] = v4[ pp[ 2 ] ];841 offset_custom += 12;842 }843 } else if ( customAttribute.boundTo === "faceVertices" ) {844 for ( f = 0, fl = chunk_faces3.length; f < fl; f ++ ) {845 value = customAttribute.value[ chunk_faces3[ f ] ];846 v1 = value[ 0 ];847 v2 = value[ 1 ];848 v3 = value[ 2 ];849 customAttribute.array[ offset_custom ] = v1[ pp[ 0 ] ];850 customAttribute.array[ offset_custom + 1 ] = v1[ pp[ 1 ] ];851 customAttribute.array[ offset_custom + 2 ] = v1[ pp[ 2 ] ];852 customAttribute.array[ offset_custom + 3 ] = v2[ pp[ 0 ] ];853 customAttribute.array[ offset_custom + 4 ] = v2[ pp[ 1 ] ];854 customAttribute.array[ offset_custom + 5 ] = v2[ pp[ 2 ] ];855 customAttribute.array[ offset_custom + 6 ] = v3[ pp[ 0 ] ];856 customAttribute.array[ offset_custom + 7 ] = v3[ pp[ 1 ] ];857 customAttribute.array[ offset_custom + 8 ] = v3[ pp[ 2 ] ];858 offset_custom += 9;859 }860 for ( f = 0, fl = chunk_faces4.length; f < fl; f ++ ) {861 value = customAttribute.value[ chunk_faces4[ f ] ];862 v1 = value[ 0 ];863 v2 = value[ 1 ];864 v3 = value[ 2 ];865 v4 = value[ 3 ];866 customAttribute.array[ offset_custom ] = v1[ pp[ 0 ] ];867 customAttribute.array[ offset_custom + 1 ] = v1[ pp[ 1 ] ];868 customAttribute.array[ offset_custom + 2 ] = v1[ pp[ 2 ] ];869 customAttribute.array[ offset_custom + 3 ] = v2[ pp[ 0 ] ];870 customAttribute.array[ offset_custom + 4 ] = v2[ pp[ 1 ] ];871 customAttribute.array[ offset_custom + 5 ] = v2[ pp[ 2 ] ];872 customAttribute.array[ offset_custom + 6 ] = v3[ pp[ 0 ] ];873 customAttribute.array[ offset_custom + 7 ] = v3[ pp[ 1 ] ];874 customAttribute.array[ offset_custom + 8 ] = v3[ pp[ 2 ] ];875 customAttribute.array[ offset_custom + 9 ] = v4[ pp[ 0 ] ];876 customAttribute.array[ offset_custom + 10 ] = v4[ pp[ 1 ] ];877 customAttribute.array[ offset_custom + 11 ] = v4[ pp[ 2 ] ];878 offset_custom += 12;879 }880 }881 } else if ( customAttribute.size === 4 ) {882 if ( customAttribute.boundTo === undefined || customAttribute.boundTo === "vertices" ) {883 for ( f = 0, fl = chunk_faces3.length; f < fl; f ++ ) {884 face = obj_faces[ chunk_faces3[ f ] ];885 v1 = customAttribute.value[ face.a ];886 v2 = customAttribute.value[ face.b ];887 v3 = customAttribute.value[ face.c ];888 customAttribute.array[ offset_custom ] = v1.x;889 customAttribute.array[ offset_custom + 1 ] = v1.y;890 customAttribute.array[ offset_custom + 2 ] = v1.z;891 customAttribute.array[ offset_custom + 3 ] = v1.w;892 customAttribute.array[ offset_custom + 4 ] = v2.x;893 customAttribute.array[ offset_custom + 5 ] = v2.y;894 customAttribute.array[ offset_custom + 6 ] = v2.z;895 customAttribute.array[ offset_custom + 7 ] = v2.w;896 customAttribute.array[ offset_custom + 8 ] = v3.x;897 customAttribute.array[ offset_custom + 9 ] = v3.y;898 customAttribute.array[ offset_custom + 10 ] = v3.z;899 customAttribute.array[ offset_custom + 11 ] = v3.w;900 offset_custom += 12;901 }902 for ( f = 0, fl = chunk_faces4.length; f < fl; f ++ ) {903 face = obj_faces[ chunk_faces4[ f ] ];904 v1 = customAttribute.value[ face.a ];905 v2 = customAttribute.value[ face.b ];906 v3 = customAttribute.value[ face.c ];907 v4 = customAttribute.value[ face.d ];908 customAttribute.array[ offset_custom ] = v1.x;909 customAttribute.array[ offset_custom + 1 ] = v1.y;910 customAttribute.array[ offset_custom + 2 ] = v1.z;911 customAttribute.array[ offset_custom + 3 ] = v1.w;912 customAttribute.array[ offset_custom + 4 ] = v2.x;913 customAttribute.array[ offset_custom + 5 ] = v2.y;914 customAttribute.array[ offset_custom + 6 ] = v2.z;915 customAttribute.array[ offset_custom + 7 ] = v2.w;916 customAttribute.array[ offset_custom + 8 ] = v3.x;917 customAttribute.array[ offset_custom + 9 ] = v3.y;918 customAttribute.array[ offset_custom + 10 ] = v3.z;919 customAttribute.array[ offset_custom + 11 ] = v3.w;920 customAttribute.array[ offset_custom + 12 ] = v4.x;921 customAttribute.array[ offset_custom + 13 ] = v4.y;922 customAttribute.array[ offset_custom + 14 ] = v4.z;923 customAttribute.array[ offset_custom + 15 ] = v4.w;924 offset_custom += 16;925 }926 } else if ( customAttribute.boundTo === "faces" ) {927 for ( f = 0, fl = chunk_faces3.length; f < fl; f ++ ) {928 value = customAttribute.value[ chunk_faces3[ f ] ];929 v1 = value;930 v2 = value;931 v3 = value;932 customAttribute.array[ offset_custom ] = v1.x;933 customAttribute.array[ offset_custom + 1 ] = v1.y;934 customAttribute.array[ offset_custom + 2 ] = v1.z;935 customAttribute.array[ offset_custom + 3 ] = v1.w;936 customAttribute.array[ offset_custom + 4 ] = v2.x;937 customAttribute.array[ offset_custom + 5 ] = v2.y;938 customAttribute.array[ offset_custom + 6 ] = v2.z;939 customAttribute.array[ offset_custom + 7 ] = v2.w;940 customAttribute.array[ offset_custom + 8 ] = v3.x;941 customAttribute.array[ offset_custom + 9 ] = v3.y;942 customAttribute.array[ offset_custom + 10 ] = v3.z;943 customAttribute.array[ offset_custom + 11 ] = v3.w;944 offset_custom += 12;945 }946 for ( f = 0, fl = chunk_faces4.length; f < fl; f ++ ) {947 value = customAttribute.value[ chunk_faces4[ f ] ];948 v1 = value;949 v2 = value;950 v3 = value;951 v4 = value;952 customAttribute.array[ offset_custom ] = v1.x;953 customAttribute.array[ offset_custom + 1 ] = v1.y;954 customAttribute.array[ offset_custom + 2 ] = v1.z;955 customAttribute.array[ offset_custom + 3 ] = v1.w;956 customAttribute.array[ offset_custom + 4 ] = v2.x;957 customAttribute.array[ offset_custom + 5 ] = v2.y;958 customAttribute.array[ offset_custom + 6 ] = v2.z;959 customAttribute.array[ offset_custom + 7 ] = v2.w;960 customAttribute.array[ offset_custom + 8 ] = v3.x;961 customAttribute.array[ offset_custom + 9 ] = v3.y;962 customAttribute.array[ offset_custom + 10 ] = v3.z;963 customAttribute.array[ offset_custom + 11 ] = v3.w;964 customAttribute.array[ offset_custom + 12 ] = v4.x;965 customAttribute.array[ offset_custom + 13 ] = v4.y;966 customAttribute.array[ offset_custom + 14 ] = v4.z;967 customAttribute.array[ offset_custom + 15 ] = v4.w;968 offset_custom += 16;969 }970 } else if ( customAttribute.boundTo === "faceVertices" ) {971 for ( f = 0, fl = chunk_faces3.length; f < fl; f ++ ) {972 value = customAttribute.value[ chunk_faces3[ f ] ];973 v1 = value[ 0 ];974 v2 = value[ 1 ];975 v3 = value[ 2 ];976 customAttribute.array[ offset_custom ] = v1.x;977 customAttribute.array[ offset_custom + 1 ] = v1.y;978 customAttribute.array[ offset_custom + 2 ] = v1.z;979 customAttribute.array[ offset_custom + 3 ] = v1.w;980 customAttribute.array[ offset_custom + 4 ] = v2.x;981 customAttribute.array[ offset_custom + 5 ] = v2.y;982 customAttribute.array[ offset_custom + 6 ] = v2.z;983 customAttribute.array[ offset_custom + 7 ] = v2.w;984 customAttribute.array[ offset_custom + 8 ] = v3.x;985 customAttribute.array[ offset_custom + 9 ] = v3.y;986 customAttribute.array[ offset_custom + 10 ] = v3.z;987 customAttribute.array[ offset_custom + 11 ] = v3.w;988 offset_custom += 12;989 }990 for ( f = 0, fl = chunk_faces4.length; f < fl; f ++ ) {991 value = customAttribute.value[ chunk_faces4[ f ] ];992 v1 = value[ 0 ];993 v2 = value[ 1 ];994 v3 = value[ 2 ];995 v4 = value[ 3 ];996 customAttribute.array[ offset_custom ] = v1.x;997 customAttribute.array[ offset_custom + 1 ] = v1.y;998 customAttribute.array[ offset_custom + 2 ] = v1.z;999 customAttribute.array[ offset_custom + 3 ] = v1.w;1000 customAttribute.array[ offset_custom + 4 ] = v2.x;1001 customAttribute.array[ offset_custom + 5 ] = v2.y;1002 customAttribute.array[ offset_custom + 6 ] = v2.z;1003 customAttribute.array[ offset_custom + 7 ] = v2.w;1004 customAttribute.array[ offset_custom + 8 ] = v3.x;1005 customAttribute.array[ offset_custom + 9 ] = v3.y;1006 customAttribute.array[ offset_custom + 10 ] = v3.z;1007 customAttribute.array[ offset_custom + 11 ] = v3.w;1008 customAttribute.array[ offset_custom + 12 ] = v4.x;1009 customAttribute.array[ offset_custom + 13 ] = v4.y;1010 customAttribute.array[ offset_custom + 14 ] = v4.z;1011 customAttribute.array[ offset_custom + 15 ] = v4.w;1012 offset_custom += 16;1013 }1014 }1015 }1016 renderer.setDynamicArrayBuffer( customAttribute.buffer, customAttribute.array);1017 }1018 }1019 if ( dispose ) {1020 delete geometryGroup.__inittedArrays;1021 delete geometryGroup.__colorArray;1022 delete geometryGroup.__normalArray;1023 delete geometryGroup.__tangentArray;1024 delete geometryGroup.__uvArray;1025 delete geometryGroup.__uv2Array;1026 delete geometryGroup.__faceArray;1027 delete geometryGroup.__vertexArray;1028 delete geometryGroup.__lineArray;1029 delete geometryGroup.__skinIndexArray;1030 delete geometryGroup.__skinWeightArray;1031 }1032 }...

Full Screen

Full Screen

index.es.mjs

Source:index.es.mjs Github

copy

Full Screen

1import parser from 'postcss-selector-parser';2import fs from 'fs';3import path from 'path';4import postcss from 'postcss';5function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {6 try {7 var info = gen[key](arg);8 var value = info.value;9 } catch (error) {10 reject(error);11 return;12 }13 if (info.done) {14 resolve(value);15 } else {16 Promise.resolve(value).then(_next, _throw);17 }18}19function _asyncToGenerator(fn) {20 return function () {21 var self = this,22 args = arguments;23 return new Promise(function (resolve, reject) {24 var gen = fn.apply(self, args);25 function _next(value) {26 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);27 }28 function _throw(err) {29 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);30 }31 _next(undefined);32 });33 };34}35function _defineProperty(obj, key, value) {36 if (key in obj) {37 Object.defineProperty(obj, key, {38 value: value,39 enumerable: true,40 configurable: true,41 writable: true42 });43 } else {44 obj[key] = value;45 }46 return obj;47}48function _objectSpread(target) {49 for (var i = 1; i < arguments.length; i++) {50 var source = arguments[i] != null ? arguments[i] : {};51 var ownKeys = Object.keys(source);52 if (typeof Object.getOwnPropertySymbols === 'function') {53 ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {54 return Object.getOwnPropertyDescriptor(source, sym).enumerable;55 }));56 }57 ownKeys.forEach(function (key) {58 _defineProperty(target, key, source[key]);59 });60 }61 return target;62}63function _slicedToArray(arr, i) {64 return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();65}66function _arrayWithHoles(arr) {67 if (Array.isArray(arr)) return arr;68}69function _iterableToArrayLimit(arr, i) {70 var _arr = [];71 var _n = true;72 var _d = false;73 var _e = undefined;74 try {75 for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {76 _arr.push(_s.value);77 if (i && _arr.length === i) break;78 }79 } catch (err) {80 _d = true;81 _e = err;82 } finally {83 try {84 if (!_n && _i["return"] != null) _i["return"]();85 } finally {86 if (_d) throw _e;87 }88 }89 return _arr;90}91function _nonIterableRest() {92 throw new TypeError("Invalid attempt to destructure non-iterable instance");93}94/* Return a Selectors AST from a Selectors String95/* ========================================================================== */96var getSelectorsAstFromSelectorsString = (selectorString => {97 let selectorAST;98 parser(selectors => {99 selectorAST = selectors;100 }).processSync(selectorString);101 return selectorAST;102});103var getCustomSelectors = ((root, opts) => {104 // initialize custom selectors105 const customSelectors = {}; // for each custom selector atrule that is a child of the css root106 root.nodes.slice().forEach(node => {107 if (isCustomSelector(node)) {108 // extract the name and selectors from the params of the custom selector109 const _node$params$match = node.params.match(customSelectorParamsRegExp),110 _node$params$match2 = _slicedToArray(_node$params$match, 3),111 name = _node$params$match2[1],112 selectors = _node$params$match2[2]; // write the parsed selectors to the custom selector113 customSelectors[name] = getSelectorsAstFromSelectorsString(selectors); // conditionally remove the custom selector atrule114 if (!Object(opts).preserve) {115 node.remove();116 }117 }118 });119 return customSelectors;120}); // match the custom selector name121const customSelectorNameRegExp = /^custom-selector$/i; // match the custom selector params122const customSelectorParamsRegExp = /^(:--[A-z][\w-]*)\s+([\W\w]+)\s*$/; // whether the atrule is a custom selector123const isCustomSelector = node => node.type === 'atrule' && customSelectorNameRegExp.test(node.name) && customSelectorParamsRegExp.test(node.params);124// return transformed selectors, replacing custom pseudo selectors with custom selectors125function transformSelectorList(selectorList, customSelectors) {126 let index = selectorList.nodes.length - 1;127 while (index >= 0) {128 const transformedSelectors = transformSelector(selectorList.nodes[index], customSelectors);129 if (transformedSelectors.length) {130 selectorList.nodes.splice(index, 1, ...transformedSelectors);131 }132 --index;133 }134 return selectorList;135} // return custom pseudo selectors replaced with custom selectors136function transformSelector(selector, customSelectors) {137 const transpiledSelectors = [];138 for (const index in selector.nodes) {139 const _selector$nodes$index = selector.nodes[index],140 value = _selector$nodes$index.value,141 nodes = _selector$nodes$index.nodes;142 if (value in customSelectors) {143 var _iteratorNormalCompletion = true;144 var _didIteratorError = false;145 var _iteratorError = undefined;146 try {147 for (var _iterator = customSelectors[value].nodes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {148 const replacementSelector = _step.value;149 const selectorClone = selector.clone();150 selectorClone.nodes.splice(index, 1, ...replacementSelector.clone().nodes.map(node => {151 // use spacing from the current usage152 node.spaces = _objectSpread({}, selector.nodes[index].spaces);153 return node;154 }));155 const retranspiledSelectors = transformSelector(selectorClone, customSelectors);156 adjustNodesBySelectorEnds(selectorClone.nodes, Number(index));157 if (retranspiledSelectors.length) {158 transpiledSelectors.push(...retranspiledSelectors);159 } else {160 transpiledSelectors.push(selectorClone);161 }162 }163 } catch (err) {164 _didIteratorError = true;165 _iteratorError = err;166 } finally {167 try {168 if (!_iteratorNormalCompletion && _iterator.return != null) {169 _iterator.return();170 }171 } finally {172 if (_didIteratorError) {173 throw _iteratorError;174 }175 }176 }177 return transpiledSelectors;178 } else if (nodes && nodes.length) {179 transformSelectorList(selector.nodes[index], customSelectors);180 }181 }182 return transpiledSelectors;183} // match selectors by difficult-to-separate ends184const withoutSelectorStartMatch = /^(tag|universal)$/;185const withoutSelectorEndMatch = /^(class|id|pseudo|tag|universal)$/;186const isWithoutSelectorStart = node => withoutSelectorStartMatch.test(Object(node).type);187const isWithoutSelectorEnd = node => withoutSelectorEndMatch.test(Object(node).type); // adjust nodes by selector ends (so that .class:--h1 becomes h1.class rather than .classh1)188const adjustNodesBySelectorEnds = (nodes, index) => {189 if (index && isWithoutSelectorStart(nodes[index]) && isWithoutSelectorEnd(nodes[index - 1])) {190 let safeIndex = index - 1;191 while (safeIndex && isWithoutSelectorEnd(nodes[safeIndex])) {192 --safeIndex;193 }194 if (safeIndex < index) {195 const node = nodes.splice(index, 1)[0];196 nodes.splice(safeIndex, 0, node);197 nodes[safeIndex].spaces.before = nodes[safeIndex + 1].spaces.before;198 nodes[safeIndex + 1].spaces.before = '';199 if (nodes[index]) {200 nodes[index].spaces.after = nodes[safeIndex].spaces.after;201 nodes[safeIndex].spaces.after = '';202 }203 }204 }205};206var transformRules = ((root, customSelectors, opts) => {207 root.walkRules(customPseudoRegExp, rule => {208 const selector = parser(selectors => {209 transformSelectorList(selectors, customSelectors, opts);210 }).processSync(rule.selector);211 if (opts.preserve) {212 rule.cloneBefore({213 selector214 });215 } else {216 rule.selector = selector;217 }218 });219});220const customPseudoRegExp = /:--[A-z][\w-]*/;221/* Import Custom Selectors from CSS AST222/* ========================================================================== */223function importCustomSelectorsFromCSSAST(root) {224 return getCustomSelectors(root);225}226/* Import Custom Selectors from CSS File227/* ========================================================================== */228function importCustomSelectorsFromCSSFile(_x) {229 return _importCustomSelectorsFromCSSFile.apply(this, arguments);230}231/* Import Custom Selectors from Object232/* ========================================================================== */233function _importCustomSelectorsFromCSSFile() {234 _importCustomSelectorsFromCSSFile = _asyncToGenerator(function* (from) {235 const css = yield readFile(path.resolve(from));236 const root = postcss.parse(css, {237 from: path.resolve(from)238 });239 return importCustomSelectorsFromCSSAST(root);240 });241 return _importCustomSelectorsFromCSSFile.apply(this, arguments);242}243function importCustomSelectorsFromObject(object) {244 const customSelectors = Object.assign({}, Object(object).customSelectors || Object(object)['custom-selectors']);245 for (const key in customSelectors) {246 customSelectors[key] = getSelectorsAstFromSelectorsString(customSelectors[key]);247 }248 return customSelectors;249}250/* Import Custom Selectors from JSON file251/* ========================================================================== */252function importCustomSelectorsFromJSONFile(_x2) {253 return _importCustomSelectorsFromJSONFile.apply(this, arguments);254}255/* Import Custom Selectors from JS file256/* ========================================================================== */257function _importCustomSelectorsFromJSONFile() {258 _importCustomSelectorsFromJSONFile = _asyncToGenerator(function* (from) {259 const object = yield readJSON(path.resolve(from));260 return importCustomSelectorsFromObject(object);261 });262 return _importCustomSelectorsFromJSONFile.apply(this, arguments);263}264function importCustomSelectorsFromJSFile(_x3) {265 return _importCustomSelectorsFromJSFile.apply(this, arguments);266}267/* Import Custom Selectors from Sources268/* ========================================================================== */269function _importCustomSelectorsFromJSFile() {270 _importCustomSelectorsFromJSFile = _asyncToGenerator(function* (from) {271 const object = yield import(path.resolve(from));272 return importCustomSelectorsFromObject(object);273 });274 return _importCustomSelectorsFromJSFile.apply(this, arguments);275}276function importCustomSelectorsFromSources(sources) {277 return sources.map(source => {278 if (source instanceof Promise) {279 return source;280 } else if (source instanceof Function) {281 return source();282 } // read the source as an object283 const opts = source === Object(source) ? source : {284 from: String(source)285 }; // skip objects with custom selectors286 if (Object(opts).customSelectors || Object(opts)['custom-selectors']) {287 return opts;288 } // source pathname289 const from = String(opts.from || ''); // type of file being read from290 const type = (opts.type || path.extname(from).slice(1)).toLowerCase();291 return {292 type,293 from294 };295 }).reduce(296 /*#__PURE__*/297 function () {298 var _ref = _asyncToGenerator(function* (customSelectors, source) {299 const _ref2 = yield source,300 type = _ref2.type,301 from = _ref2.from;302 if (type === 'ast') {303 return Object.assign(customSelectors, importCustomSelectorsFromCSSAST(from));304 }305 if (type === 'css') {306 return Object.assign(customSelectors, (yield importCustomSelectorsFromCSSFile(from)));307 }308 if (type === 'js') {309 return Object.assign(customSelectors, (yield importCustomSelectorsFromJSFile(from)));310 }311 if (type === 'json') {312 return Object.assign(customSelectors, (yield importCustomSelectorsFromJSONFile(from)));313 }314 return Object.assign(customSelectors, importCustomSelectorsFromObject((yield source)));315 });316 return function (_x4, _x5) {317 return _ref.apply(this, arguments);318 };319 }(), {});320}321/* Helper utilities322/* ========================================================================== */323const readFile = from => new Promise((resolve, reject) => {324 fs.readFile(from, 'utf8', (error, result) => {325 if (error) {326 reject(error);327 } else {328 resolve(result);329 }330 });331});332const readJSON =333/*#__PURE__*/334function () {335 var _ref3 = _asyncToGenerator(function* (from) {336 return JSON.parse((yield readFile(from)));337 });338 return function readJSON(_x6) {339 return _ref3.apply(this, arguments);340 };341}();342/* Import Custom Selectors from CSS File343/* ========================================================================== */344function exportCustomSelectorsToCssFile(_x, _x2) {345 return _exportCustomSelectorsToCssFile.apply(this, arguments);346}347/* Import Custom Selectors from JSON file348/* ========================================================================== */349function _exportCustomSelectorsToCssFile() {350 _exportCustomSelectorsToCssFile = _asyncToGenerator(function* (to, customSelectors) {351 const cssContent = Object.keys(customSelectors).reduce((cssLines, name) => {352 cssLines.push(`@custom-selector ${name} ${customSelectors[name]};`);353 return cssLines;354 }, []).join('\n');355 const css = `${cssContent}\n`;356 yield writeFile(to, css);357 });358 return _exportCustomSelectorsToCssFile.apply(this, arguments);359}360function exportCustomSelectorsToJsonFile(_x3, _x4) {361 return _exportCustomSelectorsToJsonFile.apply(this, arguments);362}363/* Import Custom Selectors from Common JS file364/* ========================================================================== */365function _exportCustomSelectorsToJsonFile() {366 _exportCustomSelectorsToJsonFile = _asyncToGenerator(function* (to, customSelectors) {367 const jsonContent = JSON.stringify({368 'custom-selectors': customSelectors369 }, null, ' ');370 const json = `${jsonContent}\n`;371 yield writeFile(to, json);372 });373 return _exportCustomSelectorsToJsonFile.apply(this, arguments);374}375function exportCustomSelectorsToCjsFile(_x5, _x6) {376 return _exportCustomSelectorsToCjsFile.apply(this, arguments);377}378/* Import Custom Selectors from Module JS file379/* ========================================================================== */380function _exportCustomSelectorsToCjsFile() {381 _exportCustomSelectorsToCjsFile = _asyncToGenerator(function* (to, customSelectors) {382 const jsContents = Object.keys(customSelectors).reduce((jsLines, name) => {383 jsLines.push(`\t\t'${escapeForJS(name)}': '${escapeForJS(customSelectors[name])}'`);384 return jsLines;385 }, []).join(',\n');386 const js = `module.exports = {\n\tcustomSelectors: {\n${jsContents}\n\t}\n};\n`;387 yield writeFile(to, js);388 });389 return _exportCustomSelectorsToCjsFile.apply(this, arguments);390}391function exportCustomSelectorsToMjsFile(_x7, _x8) {392 return _exportCustomSelectorsToMjsFile.apply(this, arguments);393}394/* Export Custom Selectors to Destinations395/* ========================================================================== */396function _exportCustomSelectorsToMjsFile() {397 _exportCustomSelectorsToMjsFile = _asyncToGenerator(function* (to, customSelectors) {398 const mjsContents = Object.keys(customSelectors).reduce((mjsLines, name) => {399 mjsLines.push(`\t'${escapeForJS(name)}': '${escapeForJS(customSelectors[name])}'`);400 return mjsLines;401 }, []).join(',\n');402 const mjs = `export const customSelectors = {\n${mjsContents}\n};\n`;403 yield writeFile(to, mjs);404 });405 return _exportCustomSelectorsToMjsFile.apply(this, arguments);406}407function exportCustomSelectorsToDestinations(customSelectors, destinations) {408 return Promise.all(destinations.map(409 /*#__PURE__*/410 function () {411 var _ref = _asyncToGenerator(function* (destination) {412 if (destination instanceof Function) {413 yield destination(defaultCustomSelectorsToJSON(customSelectors));414 } else {415 // read the destination as an object416 const opts = destination === Object(destination) ? destination : {417 to: String(destination)418 }; // transformer for custom selectors into a JSON-compatible object419 const toJSON = opts.toJSON || defaultCustomSelectorsToJSON;420 if ('customSelectors' in opts) {421 // write directly to an object as customSelectors422 opts.customSelectors = toJSON(customSelectors);423 } else if ('custom-selectors' in opts) {424 // write directly to an object as custom-selectors425 opts['custom-selectors'] = toJSON(customSelectors);426 } else {427 // destination pathname428 const to = String(opts.to || ''); // type of file being written to429 const type = (opts.type || path.extname(opts.to).slice(1)).toLowerCase(); // transformed custom selectors430 const customSelectorsJSON = toJSON(customSelectors);431 if (type === 'css') {432 yield exportCustomSelectorsToCssFile(to, customSelectorsJSON);433 }434 if (type === 'js') {435 yield exportCustomSelectorsToCjsFile(to, customSelectorsJSON);436 }437 if (type === 'json') {438 yield exportCustomSelectorsToJsonFile(to, customSelectorsJSON);439 }440 if (type === 'mjs') {441 yield exportCustomSelectorsToMjsFile(to, customSelectorsJSON);442 }443 }444 }445 });446 return function (_x9) {447 return _ref.apply(this, arguments);448 };449 }()));450}451/* Helper utilities452/* ========================================================================== */453const defaultCustomSelectorsToJSON = customSelectors => {454 return Object.keys(customSelectors).reduce((customSelectorsJSON, key) => {455 customSelectorsJSON[key] = String(customSelectors[key]);456 return customSelectorsJSON;457 }, {});458};459const writeFile = (to, text) => new Promise((resolve, reject) => {460 fs.writeFile(to, text, error => {461 if (error) {462 reject(error);463 } else {464 resolve();465 }466 });467});468const escapeForJS = string => string.replace(/\\([\s\S])|(')/g, '\\$1$2').replace(/\n/g, '\\n').replace(/\r/g, '\\r');469var index = postcss.plugin('postcss-custom-selectors', opts => {470 // whether to preserve custom selectors and rules using them471 const preserve = Boolean(Object(opts).preserve); // sources to import custom selectors from472 const importFrom = [].concat(Object(opts).importFrom || []); // destinations to export custom selectors to473 const exportTo = [].concat(Object(opts).exportTo || []); // promise any custom selectors are imported474 const customSelectorsPromise = importCustomSelectorsFromSources(importFrom);475 return (476 /*#__PURE__*/477 function () {478 var _ref = _asyncToGenerator(function* (root) {479 const customProperties = Object.assign((yield customSelectorsPromise), getCustomSelectors(root, {480 preserve481 }));482 yield exportCustomSelectorsToDestinations(customProperties, exportTo);483 transformRules(root, customProperties, {484 preserve485 });486 });487 return function (_x) {488 return _ref.apply(this, arguments);489 };490 }()491 );492});493export default index;...

Full Screen

Full Screen

index.esm.mjs

Source:index.esm.mjs Github

copy

Full Screen

1import postcss from 'postcss';2import valueParser from 'postcss-values-parser';3import fs from 'fs';4import path from 'path';5function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {6 try {7 var info = gen[key](arg);8 var value = info.value;9 } catch (error) {10 reject(error);11 return;12 }13 if (info.done) {14 resolve(value);15 } else {16 Promise.resolve(value).then(_next, _throw);17 }18}19function _asyncToGenerator(fn) {20 return function () {21 var self = this,22 args = arguments;23 return new Promise(function (resolve, reject) {24 var gen = fn.apply(self, args);25 function _next(value) {26 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);27 }28 function _throw(err) {29 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);30 }31 _next(undefined);32 });33 };34}35function parse(string) {36 return valueParser(string).parse();37}38function isBlockIgnored(ruleOrDeclaration) {39 var rule = ruleOrDeclaration.selector ? ruleOrDeclaration : ruleOrDeclaration.parent;40 return /(!\s*)?postcss-custom-properties:\s*off\b/i.test(rule.toString());41}42function isRuleIgnored(rule) {43 var previous = rule.prev();44 return Boolean(isBlockIgnored(rule) || previous && previous.type === 'comment' && /(!\s*)?postcss-custom-properties:\s*ignore\s+next\b/i.test(previous.text));45}46function getCustomPropertiesFromRoot(root, opts) {47 // initialize custom selectors48 const customPropertiesFromHtmlElement = {};49 const customPropertiesFromRootPseudo = {}; // for each html or :root rule50 root.nodes.slice().forEach(rule => {51 const customPropertiesObject = isHtmlRule(rule) ? customPropertiesFromHtmlElement : isRootRule(rule) ? customPropertiesFromRootPseudo : null; // for each custom property52 if (customPropertiesObject) {53 rule.nodes.slice().forEach(decl => {54 if (isCustomDecl(decl) && !isBlockIgnored(decl)) {55 const prop = decl.prop; // write the parsed value to the custom property56 customPropertiesObject[prop] = parse(decl.value).nodes; // conditionally remove the custom property declaration57 if (!opts.preserve) {58 decl.remove();59 }60 }61 }); // conditionally remove the empty html or :root rule62 if (!opts.preserve && isEmptyParent(rule) && !isBlockIgnored(rule)) {63 rule.remove();64 }65 }66 }); // return all custom properties, preferring :root properties over html properties67 return Object.assign({}, customPropertiesFromHtmlElement, customPropertiesFromRootPseudo);68} // match html and :root rules69const htmlSelectorRegExp = /^html$/i;70const rootSelectorRegExp = /^:root$/i;71const customPropertyRegExp = /^--[A-z][\w-]*$/; // whether the node is an html or :root rule72const isHtmlRule = node => node.type === 'rule' && htmlSelectorRegExp.test(node.selector) && Object(node.nodes).length;73const isRootRule = node => node.type === 'rule' && rootSelectorRegExp.test(node.selector) && Object(node.nodes).length; // whether the node is an custom property74const isCustomDecl = node => node.type === 'decl' && customPropertyRegExp.test(node.prop); // whether the node is a parent without children75const isEmptyParent = node => Object(node.nodes).length === 0;76/* Get Custom Properties from CSS File77/* ========================================================================== */78function getCustomPropertiesFromCSSFile(_x) {79 return _getCustomPropertiesFromCSSFile.apply(this, arguments);80}81/* Get Custom Properties from Object82/* ========================================================================== */83function _getCustomPropertiesFromCSSFile() {84 _getCustomPropertiesFromCSSFile = _asyncToGenerator(function* (from) {85 const css = yield readFile(from);86 const root = postcss.parse(css, {87 from88 });89 return getCustomPropertiesFromRoot(root, {90 preserve: true91 });92 });93 return _getCustomPropertiesFromCSSFile.apply(this, arguments);94}95function getCustomPropertiesFromObject(object) {96 const customProperties = Object.assign({}, Object(object).customProperties, Object(object)['custom-properties']);97 for (const key in customProperties) {98 customProperties[key] = parse(String(customProperties[key])).nodes;99 }100 return customProperties;101}102/* Get Custom Properties from JSON file103/* ========================================================================== */104function getCustomPropertiesFromJSONFile(_x2) {105 return _getCustomPropertiesFromJSONFile.apply(this, arguments);106}107/* Get Custom Properties from JS file108/* ========================================================================== */109function _getCustomPropertiesFromJSONFile() {110 _getCustomPropertiesFromJSONFile = _asyncToGenerator(function* (from) {111 const object = yield readJSON(from);112 return getCustomPropertiesFromObject(object);113 });114 return _getCustomPropertiesFromJSONFile.apply(this, arguments);115}116function getCustomPropertiesFromJSFile(_x3) {117 return _getCustomPropertiesFromJSFile.apply(this, arguments);118}119/* Get Custom Properties from Imports120/* ========================================================================== */121function _getCustomPropertiesFromJSFile() {122 _getCustomPropertiesFromJSFile = _asyncToGenerator(function* (from) {123 const object = yield import(from);124 return getCustomPropertiesFromObject(object);125 });126 return _getCustomPropertiesFromJSFile.apply(this, arguments);127}128function getCustomPropertiesFromImports(sources) {129 return sources.map(source => {130 if (source instanceof Promise) {131 return source;132 } else if (source instanceof Function) {133 return source();134 } // read the source as an object135 const opts = source === Object(source) ? source : {136 from: String(source)137 }; // skip objects with Custom Properties138 if (opts.customProperties || opts['custom-properties']) {139 return opts;140 } // source pathname141 const from = path.resolve(String(opts.from || '')); // type of file being read from142 const type = (opts.type || path.extname(from).slice(1)).toLowerCase();143 return {144 type,145 from146 };147 }).reduce(148 /*#__PURE__*/149 function () {150 var _ref = _asyncToGenerator(function* (customProperties, source) {151 const _ref2 = yield source,152 type = _ref2.type,153 from = _ref2.from;154 if (type === 'css') {155 return Object.assign((yield customProperties), (yield getCustomPropertiesFromCSSFile(from)));156 }157 if (type === 'js') {158 return Object.assign((yield customProperties), (yield getCustomPropertiesFromJSFile(from)));159 }160 if (type === 'json') {161 return Object.assign((yield customProperties), (yield getCustomPropertiesFromJSONFile(from)));162 }163 return Object.assign((yield customProperties), (yield getCustomPropertiesFromObject((yield source))));164 });165 return function (_x4, _x5) {166 return _ref.apply(this, arguments);167 };168 }(), {});169}170/* Helper utilities171/* ========================================================================== */172const readFile = from => new Promise((resolve, reject) => {173 fs.readFile(from, 'utf8', (error, result) => {174 if (error) {175 reject(error);176 } else {177 resolve(result);178 }179 });180});181const readJSON =182/*#__PURE__*/183function () {184 var _ref3 = _asyncToGenerator(function* (from) {185 return JSON.parse((yield readFile(from)));186 });187 return function readJSON(_x6) {188 return _ref3.apply(this, arguments);189 };190}();191function transformValueAST(root, customProperties) {192 if (root.nodes && root.nodes.length) {193 root.nodes.slice().forEach(child => {194 if (isVarFunction(child)) {195 // eslint-disable-next-line no-unused-vars196 const _child$nodes$slice = child.nodes.slice(1, -1),197 propertyNode = _child$nodes$slice[0],198 comma = _child$nodes$slice[1],199 fallbacks = _child$nodes$slice.slice(2);200 const name = propertyNode.value;201 if (name in Object(customProperties)) {202 // conditionally replace a known custom property203 const nodes = asClonedArrayWithBeforeSpacing(customProperties[name], child.raws.before);204 child.replaceWith(...nodes);205 retransformValueAST({206 nodes207 }, customProperties, name);208 } else if (fallbacks.length) {209 // conditionally replace a custom property with a fallback210 const index = root.nodes.indexOf(child);211 if (index !== -1) {212 root.nodes.splice(index, 1, ...asClonedArrayWithBeforeSpacing(fallbacks, child.raws.before));213 }214 transformValueAST(root, customProperties);215 }216 } else {217 transformValueAST(child, customProperties);218 }219 });220 }221 return root;222} // retransform the current ast without a custom property (to prevent recursion)223function retransformValueAST(root, customProperties, withoutProperty) {224 const nextCustomProperties = Object.assign({}, customProperties);225 delete nextCustomProperties[withoutProperty];226 return transformValueAST(root, nextCustomProperties);227} // match var() functions228const varRegExp = /^var$/i; // whether the node is a var() function229const isVarFunction = node => node.type === 'func' && varRegExp.test(node.value) && Object(node.nodes).length > 0; // return an array with its nodes cloned, preserving the raw230const asClonedArrayWithBeforeSpacing = (array, beforeSpacing) => {231 const clonedArray = asClonedArray(array, null);232 if (clonedArray[0]) {233 clonedArray[0].raws.before = beforeSpacing;234 }235 return clonedArray;236}; // return an array with its nodes cloned237const asClonedArray = (array, parent) => array.map(node => asClonedNode(node, parent)); // return a cloned node238const asClonedNode = (node, parent) => {239 const cloneNode = new node.constructor(node);240 for (const key in node) {241 if (key === 'parent') {242 cloneNode.parent = parent;243 } else if (Object(node[key]).constructor === Array) {244 cloneNode[key] = asClonedArray(node.nodes, cloneNode);245 } else if (Object(node[key]).constructor === Object) {246 cloneNode[key] = Object.assign({}, node[key]);247 }248 }249 return cloneNode;250};251var transformProperties = ((root, customProperties, opts) => {252 // walk decls that can be transformed253 root.walkDecls(decl => {254 if (isTransformableDecl(decl) && !isRuleIgnored(decl)) {255 const originalValue = decl.value;256 const valueAST = parse(originalValue);257 const value = String(transformValueAST(valueAST, customProperties)); // conditionally transform values that have changed258 if (value !== originalValue) {259 if (opts.preserve) {260 decl.cloneBefore({261 value262 });263 } else {264 decl.value = value;265 }266 }267 }268 });269}); // match custom properties270const customPropertyRegExp$1 = /^--[A-z][\w-]*$/; // match custom property inclusions271const customPropertiesRegExp = /(^|[^\w-])var\([\W\w]+\)/; // whether the declaration should be potentially transformed272const isTransformableDecl = decl => !customPropertyRegExp$1.test(decl.prop) && customPropertiesRegExp.test(decl.value);273/* Write Custom Properties to CSS File274/* ========================================================================== */275function writeCustomPropertiesToCssFile(_x, _x2) {276 return _writeCustomPropertiesToCssFile.apply(this, arguments);277}278/* Write Custom Properties to JSON file279/* ========================================================================== */280function _writeCustomPropertiesToCssFile() {281 _writeCustomPropertiesToCssFile = _asyncToGenerator(function* (to, customProperties) {282 const cssContent = Object.keys(customProperties).reduce((cssLines, name) => {283 cssLines.push(`\t${name}: ${customProperties[name]};`);284 return cssLines;285 }, []).join('\n');286 const css = `:root {\n${cssContent}\n}\n`;287 yield writeFile(to, css);288 });289 return _writeCustomPropertiesToCssFile.apply(this, arguments);290}291function writeCustomPropertiesToJsonFile(_x3, _x4) {292 return _writeCustomPropertiesToJsonFile.apply(this, arguments);293}294/* Write Custom Properties to Common JS file295/* ========================================================================== */296function _writeCustomPropertiesToJsonFile() {297 _writeCustomPropertiesToJsonFile = _asyncToGenerator(function* (to, customProperties) {298 const jsonContent = JSON.stringify({299 'custom-properties': customProperties300 }, null, ' ');301 const json = `${jsonContent}\n`;302 yield writeFile(to, json);303 });304 return _writeCustomPropertiesToJsonFile.apply(this, arguments);305}306function writeCustomPropertiesToCjsFile(_x5, _x6) {307 return _writeCustomPropertiesToCjsFile.apply(this, arguments);308}309/* Write Custom Properties to Module JS file310/* ========================================================================== */311function _writeCustomPropertiesToCjsFile() {312 _writeCustomPropertiesToCjsFile = _asyncToGenerator(function* (to, customProperties) {313 const jsContents = Object.keys(customProperties).reduce((jsLines, name) => {314 jsLines.push(`\t\t'${escapeForJS(name)}': '${escapeForJS(customProperties[name])}'`);315 return jsLines;316 }, []).join(',\n');317 const js = `module.exports = {\n\tcustomProperties: {\n${jsContents}\n\t}\n};\n`;318 yield writeFile(to, js);319 });320 return _writeCustomPropertiesToCjsFile.apply(this, arguments);321}322function writeCustomPropertiesToMjsFile(_x7, _x8) {323 return _writeCustomPropertiesToMjsFile.apply(this, arguments);324}325/* Write Custom Properties to Exports326/* ========================================================================== */327function _writeCustomPropertiesToMjsFile() {328 _writeCustomPropertiesToMjsFile = _asyncToGenerator(function* (to, customProperties) {329 const mjsContents = Object.keys(customProperties).reduce((mjsLines, name) => {330 mjsLines.push(`\t'${escapeForJS(name)}': '${escapeForJS(customProperties[name])}'`);331 return mjsLines;332 }, []).join(',\n');333 const mjs = `export const customProperties = {\n${mjsContents}\n};\n`;334 yield writeFile(to, mjs);335 });336 return _writeCustomPropertiesToMjsFile.apply(this, arguments);337}338function writeCustomPropertiesToExports(customProperties, destinations) {339 return Promise.all(destinations.map(340 /*#__PURE__*/341 function () {342 var _ref = _asyncToGenerator(function* (destination) {343 if (destination instanceof Function) {344 yield destination(defaultCustomPropertiesToJSON(customProperties));345 } else {346 // read the destination as an object347 const opts = destination === Object(destination) ? destination : {348 to: String(destination)349 }; // transformer for Custom Properties into a JSON-compatible object350 const toJSON = opts.toJSON || defaultCustomPropertiesToJSON;351 if ('customProperties' in opts) {352 // write directly to an object as customProperties353 opts.customProperties = toJSON(customProperties);354 } else if ('custom-properties' in opts) {355 // write directly to an object as custom-properties356 opts['custom-properties'] = toJSON(customProperties);357 } else {358 // destination pathname359 const to = String(opts.to || ''); // type of file being written to360 const type = (opts.type || path.extname(opts.to).slice(1)).toLowerCase(); // transformed Custom Properties361 const customPropertiesJSON = toJSON(customProperties);362 if (type === 'css') {363 yield writeCustomPropertiesToCssFile(to, customPropertiesJSON);364 }365 if (type === 'js') {366 yield writeCustomPropertiesToCjsFile(to, customPropertiesJSON);367 }368 if (type === 'json') {369 yield writeCustomPropertiesToJsonFile(to, customPropertiesJSON);370 }371 if (type === 'mjs') {372 yield writeCustomPropertiesToMjsFile(to, customPropertiesJSON);373 }374 }375 }376 });377 return function (_x9) {378 return _ref.apply(this, arguments);379 };380 }()));381}382/* Helper utilities383/* ========================================================================== */384const defaultCustomPropertiesToJSON = customProperties => {385 return Object.keys(customProperties).reduce((customPropertiesJSON, key) => {386 customPropertiesJSON[key] = String(customProperties[key]);387 return customPropertiesJSON;388 }, {});389};390const writeFile = (to, text) => new Promise((resolve, reject) => {391 fs.writeFile(to, text, error => {392 if (error) {393 reject(error);394 } else {395 resolve();396 }397 });398});399const escapeForJS = string => string.replace(/\\([\s\S])|(')/g, '\\$1$2').replace(/\n/g, '\\n').replace(/\r/g, '\\r');400var index = postcss.plugin('postcss-custom-properties', opts => {401 // whether to preserve custom selectors and rules using them402 const preserve = 'preserve' in Object(opts) ? Boolean(opts.preserve) : true; // sources to import custom selectors from403 const importFrom = [].concat(Object(opts).importFrom || []); // destinations to export custom selectors to404 const exportTo = [].concat(Object(opts).exportTo || []); // promise any custom selectors are imported405 const customPropertiesPromise = getCustomPropertiesFromImports(importFrom); // synchronous transform406 const syncTransform = root => {407 const customProperties = getCustomPropertiesFromRoot(root, {408 preserve409 });410 transformProperties(root, customProperties, {411 preserve412 });413 }; // asynchronous transform414 const asyncTransform =415 /*#__PURE__*/416 function () {417 var _ref = _asyncToGenerator(function* (root) {418 const customProperties = Object.assign({}, (yield customPropertiesPromise), getCustomPropertiesFromRoot(root, {419 preserve420 }));421 yield writeCustomPropertiesToExports(customProperties, exportTo);422 transformProperties(root, customProperties, {423 preserve424 });425 });426 return function asyncTransform(_x) {427 return _ref.apply(this, arguments);428 };429 }(); // whether to return synchronous function if no asynchronous operations are requested430 const canReturnSyncFunction = importFrom.length === 0 && exportTo.length === 0;431 return canReturnSyncFunction ? syncTransform : asyncTransform;432});433export default index;...

Full Screen

Full Screen

custom_pages.js

Source:custom_pages.js Github

copy

Full Screen

1/**2 * Implements hook_install().3 * Used to include our pages in seperate files.4 */5function custom_pages_install() {6 //Page Partials7 drupalgap_add_js('app/modules/custom/custom_pages/inc/page_partials/page_partials_views.js');8 drupalgap_add_js('app/modules/custom/custom_pages/inc/page_partials/page_partials_separators.js');9 10 //Logged Out11 drupalgap_add_js('app/modules/custom/custom_pages/inc/logged_out/app_home.js');12 drupalgap_add_js('app/modules/custom/custom_pages/inc/logged_out/app_tour.js');13 drupalgap_add_js('app/modules/custom/custom_pages/inc/logged_out/app_user_login.js');14 drupalgap_add_js('app/modules/custom/custom_pages/inc/logged_out/app_user_reg.js');15 drupalgap_add_js('app/modules/custom/custom_pages/inc/logged_out/app_user_pass.js');16 17 //Logged In18 drupalgap_add_js('app/modules/custom/custom_pages/inc/logged_in/app_eight_demensions.js');19 drupalgap_add_js('app/modules/custom/custom_pages/inc/logged_in/app_how_to_use.js');20 drupalgap_add_js('app/modules/custom/custom_pages/inc/logged_in/app_disclaimers.js');21 drupalgap_add_js('app/modules/custom/custom_pages/inc/logged_in/app_crisis_lines.js');22 drupalgap_add_js('app/modules/custom/custom_pages/inc/logged_in/app_my_wellness_goal.js');23 drupalgap_add_js('app/modules/custom/custom_pages/inc/logged_in/app_my_wellness_goal_activity.js');24 drupalgap_add_js('app/modules/custom/custom_pages/inc/logged_in/app_my_wellness_goal_activity_badge.js');25 drupalgap_add_js('app/modules/custom/custom_pages/inc/logged_in/app_my_achievements.js');26 drupalgap_add_js('app/modules/custom/custom_pages/inc/logged_in/app_my_account.js');27 28 //Offline29 drupalgap_add_js('app/modules/custom/custom_pages/inc/offline/app_offline.js');30}31/**32 * Implements hook_menu().33 */34function custom_pages_menu() {35 var items = {};36 37 //============//38 // Logged Out //39 //============//40 41 //Home42 items['app_home'] = {43 title: 'Welcome to AppNAME',44 page_callback: 'custom_pages_app_home_page',45 pageshow: 'custom_pages_app_home_page__ps',46 };47 48 //Tour49 items['app_tour'] = {50 title: 'Tour',51 page_callback: 'custom_pages_app_tour_page',52 pageshow: 'custom_pages_app_tour_page__ps',53 };54 55 //User Login56 items['app_user_login'] = {57 title: 'User Login',58 page_callback: 'custom_pages_app_user_login_page',59 pageshow: 'custom_pages_app_user_login_page__ps',60 options: {reloadPage: true},61 };62 63 //Usr Registration64 items['app_user_reg'] = {65 title: 'Create User Account',66 page_callback: 'custom_pages_app_user_reg_page',67 pageshow: 'custom_pages_app_user_reg_page__ps',68 options: {reloadPage: true},69 };70 71 //User Password Reset72 items['app_user_pass'] = {73 title: 'Request New Password',74 page_callback: 'custom_pages_app_user_pass_page',75 pageshow: 'custom_pages_app_user_pass_page__ps',76 options: {reloadPage: true},77 };78 79 //===========//80 // Logged In //81 //===========//82 83 //Eight Demensions Of Wellness84 items['app_eight_demensions'] = {85 title: 'Eight Dimensions of Wellness', //About Page86 page_callback: 'custom_pages_app_eight_demensions',87 pageshow: 'custom_pages_app_eight_demensions__ps',88 };89 items['app_eight_demensions_lm'] = {90 title: 'Eight Dimensions of Wellness', //Learn More Page91 page_callback: 'custom_pages_app_eight_demensions_lm',92 pageshow: 'custom_pages_app_eight_demensions_lm__ps',93 };94 95 //Wellness Goal96 items['app_wellness_goal/%'] = {97 title: 'Wellness Dimensions', //About Page98 title_callback: 'custom_pages_app_wellness_goal_title_callback',99 title_arguments: [1],100 page_callback: 'custom_pages_app_wellness_goal',101 page_arguments: [1],102 pageshow: 'custom_pages_app_wellness_goal__ps',103 options: {reloadPage: true},104 };105 items['app_wellness_goal/%/activities'] = {106 title: 'Wellness Dimensions', //Activities Page107 title_callback: 'custom_pages_app_wellness_goal_title_callback',108 title_arguments: [1],109 page_callback: 'custom_pages_app_wellness_goal_activities',110 page_arguments: [1],111 pageshow: 'custom_pages_app_wellness_goal_activities__ps',112 };113 items['app_wellness_goal/%/resources'] = {114 title: 'Wellness Dimensions', //Resources Page115 title_callback: 'custom_pages_app_wellness_goal_title_callback',116 title_arguments: [1],117 page_callback: 'custom_pages_app_wellness_goal_resources',118 page_arguments: [1],119 pageshow: 'custom_pages_app_wellness_goal_resources__ps',120 };121 122 //Activity123 items['app_wellness_goal_activity/%'] = {124 title: 'Wellness Activity', //Resources Page125 page_callback: 'custom_pages_app_wellness_goal_activity',126 page_arguments: [1],127 pageshow: 'custom_pages_app_wellness_goal_activity__ps',128 };129 //Resource130 items['app_wellness_goal_resource/%'] = {131 title: 'Wellness Resource', //Resources Page132 page_callback: 'custom_pages_app_wellness_goal_resource',133 page_arguments: [1],134 pageshow: 'custom_pages_app_wellness_goal_resource__ps',135 };136 137 //How To Use138 items['app_how_to_use'] = {139 title: 'How to Use This App',140 page_callback: 'custom_pages_app_how_to_use',141 pageshow: 'custom_pages_app_how_to_use__ps',142 };143 144 //Disclaimers145 items['app_disclaimers'] = {146 title: 'Disclaimers and Acknowledgements',147 page_callback: 'custom_pages_app_disclaimers',148 pageshow: 'custom_pages_app_disclaimers__ps',149 };150 151 //Crisis Lines152 items['app_crisis_lines'] = {153 title: 'Crisis Lines',154 page_callback: 'custom_pages_app_crisis_lines',155 pageshow: 'custom_pages_app_crisis_lines__ps',156 };157 158 //My Wellness Goals159 items['app_my_wellness_goals/%'] = {160 title: 'My Wellness Goals',161 page_callback: 'custom_pages_app_my_wellness_goals',162 page_arguments: [1],163 pageshow: 'custom_pages_app_my_wellness_goals__ps',164 options: {reloadPage: true},165 };166 items['app_my_wellness_goals/%/edit'] = {167 title: 'My Wellness Goals',168 page_callback: 'custom_pages_app_my_wellness_goals_edit',169 page_arguments: [1],170 pageshow: 'custom_pages_app_my_wellness_goals_edit__ps',171 options: {reloadPage: true},172 };173 174 //My Wellness Goal175 items['app_my_wellness_goal/%'] = {176 title: 'Wellness Goal',177 title_callback: 'custom_pages_app_my_wellness_goal_title_callback',178 title_arguments: [1],179 page_callback: 'custom_pages_app_my_wellness_goal',180 page_arguments: [1],181 pageshow: 'custom_pages_app_my_wellness_goal__ps',182 options: {reloadPage: true},183 };184 items['app_my_wellness_goal/%/resources'] = {185 title: 'Wellness Goal', //Resources Page186 title_callback: 'custom_pages_app_my_wellness_goal_title_callback',187 title_arguments: [1],188 page_callback: 'custom_pages_app_my_wellness_goal_resources',189 page_arguments: [1],190 pageshow: 'custom_pages_app_my_wellness_goal_resources__ps',191 };192 items['app_my_wellness_goal/%/about'] = {193 title: 'Wellness Goal', //Activities Page194 title_callback: 'custom_pages_app_my_wellness_goal_title_callback',195 title_arguments: [1],196 page_callback: 'custom_pages_app_my_wellness_goal_about',197 page_arguments: [1],198 pageshow: 'custom_pages_app_my_wellness_goal_about__ps',199 };200 items['app_my_wellness_goal_activities/%/edit'] = {201 title: 'Edit Activities',202 page_callback: 'custom_pages_app_my_wellness_goal_activities_edit',203 page_arguments: [1],204 pageshow: 'custom_pages_app_my_wellness_goal_activities_edit__ps',205 options: {reloadPage: true},206 };207 items['app_my_wellness_goal_all/%'] = {208 title: 'All My Activities',209 page_callback: 'custom_pages_app_my_wellness_goal_all',210 page_arguments: [1],211 pageshow: 'custom_pages_app_my_wellness_goal_all__ps',212 options: {reloadPage: true},213 };214 items['app_my_wellness_goal_all/%/resources'] = {215 title: 'All My Resources', //Resources Page216 page_callback: 'custom_pages_app_my_wellness_goal_all_resources',217 page_arguments: [1],218 pageshow: 'custom_pages_app_my_wellness_goal_all_resources__ps',219 };220 items['app_my_wellness_goal_all_activities/%/edit'] = {221 title: 'Edit All My Activities',222 page_callback: 'custom_pages_app_my_wellness_goal_all_activities_edit',223 page_arguments: [1],224 pageshow: 'custom_pages_app_my_wellness_goal_all_activities_edit__ps',225 options: {reloadPage: true},226 };227 items['app_my_wellness_goal_add/%'] = {228 title: 'Added Wellness Goal',229 page_callback: 'custom_pages_app_my_wellness_goal_add',230 page_arguments: [1],231 pageshow: 'custom_pages_app_my_wellness_goal_add__ps',232 options: {reloadPage: true},233 };234 235 //My Wellness Goal Activity236 items['app_my_wellness_goal_activity/%'] = {237 title: 'My Wellness Activity',238 page_callback: 'custom_pages_app_my_wellness_goal_activity',239 page_arguments: [1,2],240 pageshow: 'custom_pages_app_my_wellness_goal_activity__ps',241 };242 items['app_my_wellness_goal_activity/%/complete'] = {243 title: 'Wellness Activity Complete',244 page_callback: 'custom_pages_app_my_wellness_goal_activity_complete',245 page_arguments: [1,2],246 pageshow: 'custom_pages_app_my_wellness_goal_activity_complete__ps',247 options: {reloadPage: true},248 };249 250 //My Wellness Goal Resource251 items['app_my_wellness_goal_resource/%'] = {252 title: 'My Wellness Resource',253 page_callback: 'custom_pages_app_my_wellness_goal_resource',254 page_arguments: [1],255 pageshow: 'custom_pages_app_my_wellness_goal_resource__ps',256 };257 258 //My Achievements259 items['app_my_achievements'] = {260 title: 'My Achievements',261 page_callback: 'custom_pages_app_my_achievements',262 page_arguments: [1],263 pageshow: 'custom_pages_app_my_achievements__ps',264 options: {reloadPage: true},265 };266 items['app_my_achievements/badges'] = {267 title: 'My Achievements',268 page_callback: 'custom_pages_app_my_achievements_badges',269 page_arguments: [1],270 pageshow: 'custom_pages_app_my_achievements_badges__ps',271 options: {reloadPage: true},272 };273 274 //My Account275 items['app_my_account'] = {276 title: 'My Account',277 page_callback: 'custom_pages_app_my_account',278 pageshow: 'custom_pages_app_my_account__ps',279 options: {reloadPage: true},280 };281 items['app_my_account/edit_user'] = {282 title: 'Edit User Settings',283 page_callback: 'custom_pages_app_my_account_edit_user',284 pageshow: 'custom_pages_app_my_account_edit_user__ps',285 options: {reloadPage: true},286 };287 items['app_my_account/force_reset_password'] = {288 title: 'Password Expired',289 page_callback: 'custom_pages_app_my_account_force_reset_password',290 pageshow: 'custom_pages_app_my_account_force_reset_password__ps',291 options: {reloadPage: true},292 };293 items['app_my_account/edit_app'] = {294 title: 'Edit App Settings',295 page_callback: 'custom_pages_app_my_account_edit_app',296 pageshow: 'custom_pages_app_my_account_edit_app__ps',297 options: {reloadPage: true},298 };299 300 301 return items; 302}303/**304 * Implements hook_deviceready().305 * Used to alter pages before show306 */307function custom_pages_deviceready() {308 //Used to alter existing pages.309 //console.log(drupalgap);310 311 //Set the offline page312 drupalgap.menu_links['offline'].title = 'No Connection: Offline';313 drupalgap.menu_links['offline'].page_callback = 'app_offline_page';314 drupalgap.menu_links['offline'].pageshow = 'app_offline_page__ps';315 316 //Add No Nav Classes317 //drupalgap.menu_links['app_home'].options.attributes.class += 'no-app-nav ';318 //drupalgap.menu_links['app_tour'].options.attributes.class += 'no-app-nav ';319 //drupalgap.menu_links['app_user_login'].options.attributes.class += 'no-app-nav ';320 //drupalgap.menu_links['app_user_pass'].options.attributes.class += 'no-app-nav ';321 //drupalgap.menu_links['app_user_reg'].options.attributes.class += 'no-app-nav ';322 323 //Transparent Header324 drupalgap.menu_links['app_my_wellness_goal_add/%'].options.attributes.class += 'header-transparent bg-img bg-img--splash ';325 drupalgap.menu_links['app_my_wellness_goal_activity/%/complete'].options.attributes.class += 'header-transparent bg-img bg-img--splash ';326 327 //No Sub Nav328 drupalgap.menu_links['app_home'].options.attributes.class += 'no-app-sub-nav ';329 drupalgap.menu_links['app_tour'].options.attributes.class += 'no-app-sub-nav ';330 drupalgap.menu_links['app_user_login'].options.attributes.class += 'no-app-sub-nav ';331 drupalgap.menu_links['app_user_pass'].options.attributes.class += 'no-app-sub-nav ';332 drupalgap.menu_links['app_user_reg'].options.attributes.class += 'no-app-sub-nav ';333 drupalgap.menu_links['app_my_wellness_goal_add/%'].options.attributes.class += 'no-app-sub-nav ';334}335/**336 * Implements hook_services_postprocess().337 * @param {Object} options338 * @param {Object} result339 */340function custom_pages_services_postprocess(options, result) {341 try {342 $args = arg();343 switch ($args[0]) {344 case 'app_user_login':345 case 'app_user_pass':346 case 'app_user_reg':347 // If there were any form errors, alert them to the user.348 if (!result.responseText) { return; }349 var response = JSON.parse(result.responseText);350 if ($.isArray(response)) {351 var msg = '';352 for (var index in response) {353 if (!response.hasOwnProperty(index)) { continue; }354 var message = response[index];355 msg += t(message) + '\n';356 }357 if (msg != '') { drupalgap_alert(msg); }358 }359 break;360 361 default:362 return;363 }364 }365 catch (error) { console.log('custom_pages_services_postprocess - ' + error); }...

Full Screen

Full Screen

ParticleRenderer.js

Source:ParticleRenderer.js Github

copy

Full Screen

1THREE.WebGLRenderer.ParticleRenderer = function ( lowlevelrenderer, info ) {2 THREE.WebGLRenderer.Object3DRenderer.call( this, lowlevelrenderer, info );3};4THREE.WebGLRenderer.ParticleRenderer.prototype = Object.create( THREE.WebGLRenderer.Object3DRenderer.prototype );5THREE.extend( THREE.WebGLRenderer.ParticleRenderer.prototype, {6 createBuffers: function ( geometry ) {7 var renderer = this.renderer;8 geometry.__webglVertexBuffer = renderer.createBuffer();9 geometry.__webglColorBuffer = renderer.createBuffer();10 this.info.memory.geometries ++;11 },12 initBuffers: function ( geometry, object ) {13 var nvertices = geometry.vertices.length;14 geometry.__vertexArray = new Float32Array( nvertices * 3 );15 geometry.__colorArray = new Float32Array( nvertices * 3 );16 geometry.__sortArray = [];17 geometry.__webglParticleCount = nvertices;18 this.initCustomAttributes ( geometry, object );19 },20 setBuffers: function ( geometry, object , projectionScreenMatrix ) {21 var renderer = this.renderer;22 var v, c, vertex, offset, index, color,23 vertices = geometry.vertices,24 vl = vertices.length,25 colors = geometry.colors,26 cl = colors.length,27 vertexArray = geometry.__vertexArray,28 colorArray = geometry.__colorArray,29 sortArray = geometry.__sortArray,30 dirtyVertices = geometry.verticesNeedUpdate,31 dirtyElements = geometry.elementsNeedUpdate,32 dirtyColors = geometry.colorsNeedUpdate,33 customAttributes = geometry.__webglCustomAttributesList,34 i, il,35 a, ca, cal, value,36 customAttribute;37 var _projScreenMatrixPS = THREE.WebGLRenderer.ParticleRenderer._m1,38 _vector3 = THREE.WebGLRenderer.ParticleRenderer._v1;39 if ( object.sortParticles ) {40 _projScreenMatrixPS.multiplyMatrices( projectionScreenMatrix, object.matrixWorld );41 for ( v = 0; v < vl; v ++ ) {42 vertex = vertices[ v ];43 _vector3.copy( vertex );44 _vector3.applyProjection(_projScreenMatrixPS);45 sortArray[ v ] = [ _vector3.z, v ];46 }47 sortArray.sort( this.numericalSort );48 for ( v = 0; v < vl; v ++ ) {49 vertex = vertices[ sortArray[v][1] ];50 offset = v * 3;51 vertexArray[ offset ] = vertex.x;52 vertexArray[ offset + 1 ] = vertex.y;53 vertexArray[ offset + 2 ] = vertex.z;54 }55 for ( c = 0; c < cl; c ++ ) {56 offset = c * 3;57 color = colors[ sortArray[c][1] ];58 colorArray[ offset ] = color.r;59 colorArray[ offset + 1 ] = color.g;60 colorArray[ offset + 2 ] = color.b;61 }62 if ( customAttributes ) {63 for ( i = 0, il = customAttributes.length; i < il; i ++ ) {64 customAttribute = customAttributes[ i ];65 if ( ! ( customAttribute.boundTo === undefined || customAttribute.boundTo === "vertices" ) ) continue;66 offset = 0;67 cal = customAttribute.value.length;68 if ( customAttribute.size === 1 ) {69 for ( ca = 0; ca < cal; ca ++ ) {70 index = sortArray[ ca ][ 1 ];71 customAttribute.array[ ca ] = customAttribute.value[ index ];72 }73 } else if ( customAttribute.size === 2 ) {74 for ( ca = 0; ca < cal; ca ++ ) {75 index = sortArray[ ca ][ 1 ];76 value = customAttribute.value[ index ];77 customAttribute.array[ offset ] = value.x;78 customAttribute.array[ offset + 1 ] = value.y;79 offset += 2;80 }81 } else if ( customAttribute.size === 3 ) {82 if ( customAttribute.type === "c" ) {83 for ( ca = 0; ca < cal; ca ++ ) {84 index = sortArray[ ca ][ 1 ];85 value = customAttribute.value[ index ];86 customAttribute.array[ offset ] = value.r;87 customAttribute.array[ offset + 1 ] = value.g;88 customAttribute.array[ offset + 2 ] = value.b;89 offset += 3;90 }91 } else {92 for ( ca = 0; ca < cal; ca ++ ) {93 index = sortArray[ ca ][ 1 ];94 value = customAttribute.value[ index ];95 customAttribute.array[ offset ] = value.x;96 customAttribute.array[ offset + 1 ] = value.y;97 customAttribute.array[ offset + 2 ] = value.z;98 offset += 3;99 }100 }101 } else if ( customAttribute.size === 4 ) {102 for ( ca = 0; ca < cal; ca ++ ) {103 index = sortArray[ ca ][ 1 ];104 value = customAttribute.value[ index ];105 customAttribute.array[ offset ] = value.x;106 customAttribute.array[ offset + 1 ] = value.y;107 customAttribute.array[ offset + 2 ] = value.z;108 customAttribute.array[ offset + 3 ] = value.w;109 offset += 4;110 }111 }112 }113 }114 } else {115 if ( dirtyVertices ) {116 for ( v = 0; v < vl; v ++ ) {117 vertex = vertices[ v ];118 offset = v * 3;119 vertexArray[ offset ] = vertex.x;120 vertexArray[ offset + 1 ] = vertex.y;121 vertexArray[ offset + 2 ] = vertex.z;122 }123 }124 if ( dirtyColors ) {125 for ( c = 0; c < cl; c ++ ) {126 color = colors[ c ];127 offset = c * 3;128 colorArray[ offset ] = color.r;129 colorArray[ offset + 1 ] = color.g;130 colorArray[ offset + 2 ] = color.b;131 }132 }133 if ( customAttributes ) {134 for ( i = 0, il = customAttributes.length; i < il; i ++ ) {135 customAttribute = customAttributes[ i ];136 if ( customAttribute.needsUpdate &&137 ( customAttribute.boundTo === undefined ||138 customAttribute.boundTo === "vertices") ) {139 cal = customAttribute.value.length;140 offset = 0;141 if ( customAttribute.size === 1 ) {142 for ( ca = 0; ca < cal; ca ++ ) {143 customAttribute.array[ ca ] = customAttribute.value[ ca ];144 }145 } else if ( customAttribute.size === 2 ) {146 for ( ca = 0; ca < cal; ca ++ ) {147 value = customAttribute.value[ ca ];148 customAttribute.array[ offset ] = value.x;149 customAttribute.array[ offset + 1 ] = value.y;150 offset += 2;151 }152 } else if ( customAttribute.size === 3 ) {153 if ( customAttribute.type === "c" ) {154 for ( ca = 0; ca < cal; ca ++ ) {155 value = customAttribute.value[ ca ];156 customAttribute.array[ offset ] = value.r;157 customAttribute.array[ offset + 1 ] = value.g;158 customAttribute.array[ offset + 2 ] = value.b;159 offset += 3;160 }161 } else {162 for ( ca = 0; ca < cal; ca ++ ) {163 value = customAttribute.value[ ca ];164 customAttribute.array[ offset ] = value.x;165 customAttribute.array[ offset + 1 ] = value.y;166 customAttribute.array[ offset + 2 ] = value.z;167 offset += 3;168 }169 }170 } else if ( customAttribute.size === 4 ) {171 for ( ca = 0; ca < cal; ca ++ ) {172 value = customAttribute.value[ ca ];173 customAttribute.array[ offset ] = value.x;174 customAttribute.array[ offset + 1 ] = value.y;175 customAttribute.array[ offset + 2 ] = value.z;176 customAttribute.array[ offset + 3 ] = value.w;177 offset += 4;178 }179 }180 }181 }182 }183 }184 if ( dirtyVertices || object.sortParticles ) {185 renderer.setDynamicArrayBuffer(geometry.__webglVertexBuffer,vertexArray);186 }187 if ( dirtyColors || object.sortParticles ) {188 renderer.setDynamicArrayBuffer(geometry.__webglColorBuffer,colorArray);189 }190 if ( customAttributes ) {191 for ( i = 0, il = customAttributes.length; i < il; i ++ ) {192 customAttribute = customAttributes[ i ];193 if ( customAttribute.needsUpdate || object.sortParticles ) {194 renderer.setDynamicArrayBuffer(customAttribute.buffer,customAttribute.array);195 }196 }197 }198 }199} );200THREE.WebGLRenderer.ParticleRenderer._m1 = new THREE.Matrix4();...

Full Screen

Full Screen

jquery.customforms.js

Source:jquery.customforms.js Github

copy

Full Screen

1/*2 * jQuery Custom Forms Plugin 1.03 * www.ZURB.com4 * Copyright 2010, ZURB5 * Free to use under the MIT license.6 * http://www.opensource.org/licenses/mit-license.php7*/8jQuery(document).ready(function ($) {9 10 function appendCustomMarkup(type) {11 $('form.custom input:' + type).each(function () {12 var $this = $(this).hide(),13 $span = $this.next('span.custom.' + type);14 if ($span.length === 0) {15 $span = $('<span class="custom ' + type + '"></span>').insertAfter($this);16 }17 $span.toggleClass('checked', $this.is(':checked'));18 });19 }20 appendCustomMarkup('checkbox');21 appendCustomMarkup('radio');22 function appendCustomSelect(sel) {23 var $this = $(sel),24 $customSelect = $this.next('div.custom.dropdown'),25 $options = $this.find('option'),26 maxWidth = 0,27 $li;28 if ($customSelect.length === 0) {29 $customSelect = $('<div class="custom dropdown"><a href="#" class="selector"></a><ul></ul></div>"');30 $options.each(function () {31 $li = $('<li>' + $(this).html() + '</li>');32 $customSelect.find('ul').append($li);33 });34 $customSelect.prepend('<a href="#" class="current">' + $options.first().html() + '</a>');35 $this.after($customSelect);36 $this.hide();37 38 } else {39 // refresh the ul with options from the select in case the supplied markup doesn't match40 $customSelect.find('ul').html('');41 $options.each(function () {42 $li = $('<li>' + $(this).html() + '</li>');43 $customSelect.find('ul').append($li);44 });45 }46 $options.each(function (index) {47 if (this.selected) {48 $customSelect.find('li').eq(index).addClass('selected');49 $customSelect.find('.current').html($(this).html());50 }51 });52 $customSelect.find('li').each(function () {53 $customSelect.addClass('open');54 if ($(this).outerWidth() > maxWidth) {55 maxWidth = $(this).outerWidth();56 }57 $customSelect.removeClass('open');58 });59 $customSelect.css('width', maxWidth + 18 + 'px');60 $customSelect.find('ul').css('width', maxWidth + 16 + 'px');61 }62 $('form.custom select').each(function () {63 appendCustomSelect(this);64 });65 66});67(function ($) {68 69 function refreshCustomSelect($select) {70 var maxWidth = 0,71 $customSelect = $select.next();72 $options = $select.find('option');73 $customSelect.find('ul').html('');74 75 $options.each(function () {76 $li = $('<li>' + $(this).html() + '</li>');77 $customSelect.find('ul').append($li);78 });79 80 // re-populate81 $options.each(function (index) {82 if (this.selected) {83 $customSelect.find('li').eq(index).addClass('selected');84 $customSelect.find('.current').html($(this).html());85 }86 });87 88 // fix width89 $customSelect.removeAttr('style')90 .find('ul').removeAttr('style');91 $customSelect.find('li').each(function () {92 $customSelect.addClass('open');93 if ($(this).outerWidth() > maxWidth) {94 maxWidth = $(this).outerWidth();95 }96 $customSelect.removeClass('open');97 });98 $customSelect.css('width', maxWidth + 18 + 'px');99 $customSelect.find('ul').css('width', maxWidth + 16 + 'px');100 101 }102 103 function toggleCheckbox($element) {104 var $input = $element.prev(),105 input = $input[0];106 input.checked = ((input.checked) ? false : true);107 $element.toggleClass('checked');108 109 $input.trigger('change');110 }111 112 function toggleRadio($element) {113 var $input = $element.prev(),114 input = $input[0];115 $('input:radio[name="' + $input.attr('name') + '"]').each(function () {116 $(this).next().removeClass('checked');117 });118 input.checked = ((input.checked) ? false : true);119 $element.toggleClass('checked');120 121 $input.trigger('change');122 }123 124 $('form.custom span.custom.checkbox').live('click', function (event) {125 event.preventDefault();126 event.stopPropagation();127 128 toggleCheckbox($(this));129 });130 131 $('form.custom span.custom.radio').live('click', function (event) {132 event.preventDefault();133 event.stopPropagation();134 135 toggleRadio($(this));136 });137 138 $('form.custom select').live('change', function (event) {139 refreshCustomSelect($(this));140 });141 142 $('form.custom label').live('click', function (event) {143 var $associatedElement = $('#' + $(this).attr('for')),144 $customCheckbox,145 $customRadio;146 if ($associatedElement.length !== 0) {147 if ($associatedElement.attr('type') === 'checkbox') {148 event.preventDefault();149 $customCheckbox = $(this).find('span.custom.checkbox');150 toggleCheckbox($customCheckbox);151 } else if ($associatedElement.attr('type') === 'radio') {152 event.preventDefault();153 $customRadio = $(this).find('span.custom.radio');154 toggleRadio($customRadio);155 }156 }157 });158 $('form.custom div.custom.dropdown a.current, form.custom div.custom.dropdown a.selector').live('click', function (event) {159 var $this = $(this),160 $dropdown = $this.closest('div.custom.dropdown');161 162 event.preventDefault();163 $dropdown.toggleClass('open');164 165 if ($dropdown.hasClass('open')) {166 $(document).bind('click.customdropdown', function (event) {167 $dropdown.removeClass('open');168 $(document).unbind('.customdropdown');169 });170 } else {171 $(document).unbind('.customdropdown');172 }173 });174 175 $('form.custom div.custom.dropdown li').live('click', function (event) {176 var $this = $(this),177 $customDropdown = $this.closest('div.custom.dropdown'),178 $select = $customDropdown.prev(),179 selectedIndex = 0;180 181 event.preventDefault();182 event.stopPropagation();183 184 $this185 .closest('ul')186 .find('li')187 .removeClass('selected');188 $this.addClass('selected');189 190 $customDropdown191 .removeClass('open')192 .find('a.current')193 .html($this.html());194 195 $this.closest('ul').find('li').each(function (index) {196 if ($this[0] == this) {197 selectedIndex = index;198 }199 200 });201 $select[0].selectedIndex = selectedIndex;202 203 $select.trigger('change');204 });...

Full Screen

Full Screen

custom_blocks.js

Source:custom_blocks.js Github

copy

Full Screen

1/**2 * Implements hook_install().3 * Used to include our blocks in seperate files.4 */5function custom_blocks_install() {6 //Slide Menu7 drupalgap_add_js('app/modules/custom/custom_blocks/inc/headerMenus.js');8 9 //SubMenus10 drupalgap_add_js('app/modules/custom/custom_blocks/inc/subMenus.js');11 12 //Header Buttons13 drupalgap_add_js('app/modules/custom/custom_blocks/inc/headerButtons.js');14 15 //Header Blocks16 drupalgap_add_js('app/modules/custom/custom_blocks/inc/headerBlocks.js')17}18/**19 * Implements hook_block_info().20 */21function custom_blocks_block_info() {22 var blocks = {};23 //Header Menus24 blocks['slide_menu_block'] = {25 delta: 'slide_menu_block',26 module: 'custom_blocks'27 };28 blocks['slide_menu_block_button'] = {29 delta: 'slide_menu_block_button',30 module: 'custom_blocks'31 };32 33 //Header Buttons34 blocks['custom_back_button'] = {35 delta: 'custom_back_button',36 module: 'custom_blocks'37 };38 blocks['custom_cancel_button'] = {39 delta: 'custom_cancel_button',40 module: 'custom_blocks'41 };42 blocks['custom_edit_button'] = {43 delta: 'custom_edit_button',44 module: 'custom_blocks'45 };46 47 //Header Blocks48 blocks['app_title_header_block'] = {49 delta: 'app_title_header_block',50 module: 'custom_blocks'51 };52 53 //SubMenus54 blocks['eight_demensions_submenu'] = {55 delta: 'eight_demensions_submenu',56 module: 'custom_blocks'57 };58 blocks['wellness_demensions_submenu'] = {59 delta: 'wellness_demensions_submenu',60 module: 'custom_blocks'61 };62 blocks['my_wellness_goal_submenu'] = {63 delta: 'my_wellness_goal_submenu',64 module: 'custom_blocks'65 };66 blocks['my_account_edit_submenu'] = {67 delta: 'my_account_edit_submenu',68 module: 'custom_blocks'69 };70 blocks['my_achievements_submenu'] = {71 delta: 'my_achievements_submenu',72 module: 'custom_blocks'73 };74 return blocks;75}76/**77 * Implements hook_block_view().78 */79function custom_blocks_block_view(delta, region) {80 switch (delta) {81 //Header Menus82 case 'slide_menu_block':83 return custom_blocks_slide_menu_block(delta, region);84 break;85 case 'slide_menu_block_button':86 return custom_blocks_slide_menu_block_button(delta, region);87 break;88 89 //HeaderButtons90 case 'custom_back_button':91 return custom_blocks_custom_back_button(delta, region);92 break;93 case 'custom_cancel_button':94 return custom_blocks_custom_cancel_button(delta, region);95 break;96 case 'custom_edit_button':97 return custom_blocks_custom_edit_button(delta, region);98 break;99 100 //Header Blocks101 case 'app_title_header_block':102 return custom_blocks_app_title_header_block(delta, region);103 break;104 105 //SubMenus106 case 'eight_demensions_submenu':107 return custom_blocks_eight_demensions_submenu(delta, region);108 break;109 case 'wellness_demensions_submenu':110 return custom_blocks_wellness_demensions_submenu(delta, region);111 break;112 case 'my_wellness_goal_submenu':113 return custom_blocks_my_wellness_goal_submenu(delta, region);114 break;115 case 'my_account_edit_submenu':116 return custom_blocks_my_account_edit_submenu(delta, region);117 break;118 case 'my_achievements_submenu':119 return custom_blocks_my_achievements_submenu(delta, region);120 break;121 }122}123//Default Drupalgap Access Callbacks124function custom_blocks_title_header_block_access(options) {125 //console.log(options); // Un-comment to reveal info about the current context.126 var access = true;127 var args = arg(null, options.path);128 switch (args[0]) {129 case 'app_home':130 case 'app_tour':131 case 'app_user_login':132 case 'app_user_pass':133 case 'app_user_reg':134 case 'app_my_wellness_goal_add':135 return false;136 break;137 }138 return access;...

Full Screen

Full Screen

bootstrap-table-custom-view.js

Source:bootstrap-table-custom-view.js Github

copy

Full Screen

1/**2 * @author zhixin wen <wenzhixin2010@gmail.com>3 */4const Utils = $.fn.bootstrapTable.utils5$.extend($.fn.bootstrapTable.defaults, {6 customView: false,7 showCustomView: false,8 showCustomViewButton: false9})10$.extend($.fn.bootstrapTable.defaults.icons, {11 customView: {12 bootstrap3: 'glyphicon glyphicon-eye-open',13 bootstrap5: 'bi-eye',14 bootstrap4: 'fa fa-eye',15 semantic: 'fa fa-eye',16 foundation: 'fa fa-eye',17 bulma: 'fa fa-eye',18 materialize: 'remove_red_eye'19 }[$.fn.bootstrapTable.theme] || 'fa-eye'20})21$.extend($.fn.bootstrapTable.defaults, {22 onCustomViewPostBody () {23 return false24 },25 onCustomViewPreBody () {26 return false27 }28})29$.extend($.fn.bootstrapTable.locales, {30 formatToggleCustomView () {31 return 'Toggle custom view'32 }33})34$.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales)35$.fn.bootstrapTable.methods.push('toggleCustomView')36$.extend($.fn.bootstrapTable.Constructor.EVENTS, {37 'custom-view-post-body.bs.table': 'onCustomViewPostBody',38 'custom-view-pre-body.bs.table': 'onCustomViewPreBody'39})40$.BootstrapTable = class extends $.BootstrapTable {41 init () {42 this.showCustomView = this.options.showCustomView43 super.init()44 }45 initToolbar (...args) {46 if (this.options.customView && this.options.showCustomViewButton) {47 this.buttons = Object.assign(this.buttons, {48 customView: {49 text: this.options.formatToggleCustomView(),50 icon: this.options.icons.customView,51 event: this.toggleCustomView,52 attributes: {53 'aria-label': this.options.formatToggleCustomView(),54 title: this.options.formatToggleCustomView()55 }56 }57 })58 }59 super.initToolbar(...args)60 }61 initBody () {62 super.initBody()63 if (!this.options.customView) {64 return65 }66 const $table = this.$el67 const $customViewContainer = this.$container.find('.fixed-table-custom-view')68 $table.hide()69 $customViewContainer.hide()70 if (!this.options.customView || !this.showCustomView) {71 $table.show()72 return73 }74 const data = this.getData().slice(this.pageFrom - 1, this.pageTo)75 const value = Utils.calculateObjectValue(this, this.options.customView, [data], '')76 this.trigger('custom-view-pre-body', data, value)77 if ($customViewContainer.length === 1) {78 $customViewContainer.show().html(value)79 } else {80 this.$tableBody.after(`<div class="fixed-table-custom-view">${value}</div>`)81 }82 this.trigger('custom-view-post-body', data, value)83 }84 toggleCustomView () {85 this.showCustomView = !this.showCustomView86 this.initBody()87 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriverio = require('webdriverio');2var options = {3 desiredCapabilities: {4 }5};6 .remote(options)7 .init()8 .setValue('#lst-ib', 'WebdriverIO')9 .click('input[name="btnK"]')10 .getTitle().then(function(title) {11 console.log('Title is: ' + title);12 })13 .end();14exports.config = {15 capabilities: [{16 }],17 mochaOpts: {18 },19 onPrepare: function() {20 console.log("***** custom method *****");21 browser.addCommand("customMethod", function() {22 console.log("***** custom method *****");23 });24 },25 before: function() {26 console.log("***** before *****");27 },28 beforeSuite: function() {29 console.log("***** before suite *****");30 },31 beforeTest: function() {32 console.log("***** before test *****");33 },34 beforeCommand: function() {35 console.log("***** before command *****");36 },37 afterCommand: function() {38 console.log("***** after command *****");39 },40 afterTest: function() {41 console.log("***** after test *****");42 },43 afterSuite: function() {44 console.log("***** after suite *****");45 },46 after: function() {47 console.log("***** after *****");48 },49 onComplete: function() {50 console.log("***** after complete *****");51 }52};

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriverio = require('webdriverio');2var options = {3 desiredCapabilities: {4 }5};6 .remote(options)7 .init()8 .getTitle().then(function(title) {9 console.log('Title was: ' + title);10 })11 .end();12var webdriverio = require('webdriverio');13var options = {14 desiredCapabilities: {15 }16};17 .remote(options)18 .init()19 .getTitle().then(function(title) {20 console.log('Title was: ' + title);21 })22 .end();23var webdriverio = require('webdriverio');24var options = {25 desiredCapabilities: {26 }27};28 .remote(options)29 .init()30 .getTitle().then(function(title) {31 console.log('Title was: ' + title);32 })33 .end();34var webdriverio = require('webdriverio');35var options = {36 desiredCapabilities: {37 }38};39 .remote(options)40 .init()41 .getTitle().then(function(title) {42 console.log('Title was: ' + title);43 })44 .end();45var webdriverio = require('webdriverio');46var options = {47 desiredCapabilities: {48 }49};50 .remote(options)51 .init()

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriverio = require('webdriverio');2var options = {3 desiredCapabilities: {4 }5};6 .remote(options)7 .init()8 .getTitle().then(function(title) {9 console.log('Title was: ' + title);10 })11 .end();12webdriverio.addCommand("getTitle", function(){13 return this.title();14});1

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriverio = require('webdriverio');2var options = { desiredCapabilities: { browserName: 'chrome' } };3var client = webdriverio.remote(options);4client.init()5 .getTitle(function(err, title) {6 console.log('Title was: ' + title);7 })8 .setValue('#lst-ib', 'WebdriverIO')9 .click('#tsbb')10 .getTitle(function(err, title) {11 console.log('Title is: ' + title);12 })13 .end();14var webdriverio = require('webdriverio');15var options = { desiredCapabilities: { browserName: 'chrome' } };16var client = webdriverio.remote(options);17client.addCommand("myCustomCommand", function (param1, param2) {18 console.log("myCustomCommand is called with params: " + param1 + " and " + param2);19});20module.exports = client;

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriverio = require('webdriverio');2webdriverio.addCommand("getHTML", function(selector, callback) {3 this.element(selector, function(err, res) {4 this.elementIdAttribute(res.value.ELEMENT, "innerHTML", callback);5 });6});7var webdriverio = require('webdriverio');8webdriverio.addCommand("getHTML", function(selector, callback) {9 this.element(selector, function(err, res) {10 this.elementIdAttribute(res.value.ELEMENT, "innerHTML", callback);11 });12});13var webdriverio = require('webdriverio');14webdriverio.addCommand("getHTML", function(selector, callback) {15 this.element(selector, function(err, res) {16 this.elementIdAttribute(res.value.ELEMENT, "innerHTML", callback);17 });18});19var webdriverio = require('webdriverio');20webdriverio.addCommand("getHTML", function(selector, callback) {21 this.element(selector, function(err, res) {22 this.elementIdAttribute(res.value.ELEMENT, "innerHTML", callback);23 });24});25var webdriverio = require('webdriverio');26webdriverio.addCommand("getHTML", function(selector, callback) {27 this.element(selector, function(err, res) {28 this.elementIdAttribute(res.value.ELEMENT, "innerHTML", callback);29 });30});31var webdriverio = require('webdriverio');32webdriverio.addCommand("getHTML", function(selector, callback) {33 this.element(selector, function(err, res) {34 this.elementIdAttribute(res.value.ELEMENT, "innerHTML", callback);35 });36});37var webdriverio = require('webdriverio');

Full Screen

Using AI Code Generation

copy

Full Screen

1browser.addCommand("waitUntilTextExists", function (selector, expectedText, timeout) {2 var self = this;3 var startTime = new Date().getTime();4 var endTime = startTime + timeout;5 var condition = false;6 while (new Date().getTime() < endTime) {7 var text = self.getText(selector);8 if (text === expectedText) {9 condition = true;10 break;11 }12 }13 if (!condition) {14 throw new Error("Text not found");15 }16});17browser.addCommand("waitUntilTextExists", function (selector, expectedText, timeout) {18 var self = this;19 var startTime = new Date().getTime();20 var endTime = startTime + timeout;21 var condition = false;22 while (new Date().getTime() < endTime) {23 var text = self.getText(selector);24 if (text === expectedText) {25 condition = true;26 break;27 }28 }29 if (!condition) {30 throw new Error("Text not found");31 }32});33browser.addCommand("waitUntilTextExists", function (selector, expectedText, timeout) {34 var self = this;35 var startTime = new Date().getTime();36 var endTime = startTime + timeout;37 var condition = false;38 while (new Date().getTime() < endTime) {39 var text = self.getText(selector);40 if (text === expectedText) {41 condition = true;42 break;43 }44 }45 if (!condition) {46 throw new Error("Text not found");47 }48});49browser.addCommand("waitUntilTextExists", function (selector, expectedText, timeout) {50 var self = this;51 var startTime = new Date().getTime();52 var endTime = startTime + timeout;53 var condition = false;54 while (new Date().getTime() < endTime) {55 var text = self.getText(selector);56 if (text === expectedText) {57 condition = true;58 break;59 }60 }61 if (!condition) {62 throw new Error("Text not found");63 }64});65browser.addCommand("waitUntilTextExists", function (selector, expectedText, timeout) {66 var self = this;

Full Screen

Using AI Code Generation

copy

Full Screen

1describe("Custom method", function() {2 it("should use custom method", function() {3 browser.pause(5000);4 });5});6exports.config = {7 jasmineNodeOpts: {8 },9 before: function () {10 browser.addCommand("customClick", function (selector) {11 var element = $(selector);12 element.waitForExist();13 element.click();14 });15 }16};

Full Screen

WebdriverIO Tutorial

Wondering what could be a next-gen browser and mobile test automation framework that is also simple and concise? Yes, that’s right, it's WebdriverIO. Since the setup is very easy to follow compared to Selenium testing configuration, you can configure the features manually thereby being the center of attraction for automation testing. Therefore the testers adopt WedriverIO to fulfill their needs of browser testing.

Learn to run automation testing with WebdriverIO tutorial. Go from a beginner to a professional automation test expert with LambdaTest WebdriverIO tutorial.

Chapters

  1. Running Your First Automation Script - Learn the steps involved to execute your first Test Automation Script using WebdriverIO since the setup is very easy to follow and the features can be configured manually.

  2. Selenium Automation With WebdriverIO - Read more about automation testing with WebdriverIO and how it supports both browsers and mobile devices.

  3. Browser Commands For Selenium Testing - Understand more about the barriers faced while working on your Selenium Automation Scripts in WebdriverIO, the ‘browser’ object and how to use them?

  4. Handling Alerts & Overlay In Selenium - Learn different types of alerts faced during automation, how to handle these alerts and pops and also overlay modal in WebdriverIO.

  5. How To Use Selenium Locators? - Understand how Webdriver uses selenium locators in a most unique way since having to choose web elements very carefully for script execution is very important to get stable test results.

  6. Deep Selectors In Selenium WebdriverIO - The most popular automation testing framework that is extensively adopted by all the testers at a global level is WebdriverIO. Learn how you can use Deep Selectors in Selenium WebdriverIO.

  7. Handling Dropdown In Selenium - Learn more about handling dropdowns and how it's important while performing automated browser testing.

  8. Automated Monkey Testing with Selenium & WebdriverIO - Understand how you can leverage the amazing quality of WebdriverIO along with selenium framework to automate monkey testing of your website or web applications.

  9. JavaScript Testing with Selenium and WebdriverIO - Speed up your Javascript testing with Selenium and WebdriverIO.

  10. Cross Browser Testing With WebdriverIO - Learn more with this step-by-step tutorial about WebdriverIO framework and how cross-browser testing is done with WebdriverIO.

Run Webdriverio automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful