/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import{create as r}from"../../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as o}from"../../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{DoublePrecision as e}from"../util/DoublePrecision.glsl.js";import{Float3DrawUniform as a}from"../../shaderModules/Float3DrawUniform.js";import{Float3PassUniform as i}from"../../shaderModules/Float3PassUniform.js";import{glsl as t}from"../../shaderModules/glsl.js";import{Matrix3DrawUniform as m}from"../../shaderModules/Matrix3DrawUniform.js";import{Matrix3PassUniform as s}from"../../shaderModules/Matrix3PassUniform.js";import{Matrix4BindUniform as d}from"../../shaderModules/Matrix4BindUniform.js";import{NoParameters as l}from"../../../../../webgl/NoParameters.js";function n(r,o){const{attributes:l,vertex:n,varyings:f,fragment:v}=r;n.include(e,o),l.add("position","vec3"),f.add("vPositionWorldCameraRelative","vec3"),f.add("vPosition_view","vec3",{invariant:!0}),n.uniforms.add(new i("transformWorldFromViewTH",r=>r.transformWorldFromViewTH),new i("transformWorldFromViewTL",r=>r.transformWorldFromViewTL),new s("transformViewFromCameraRelativeRS",r=>r.transformViewFromCameraRelativeRS),new d("transformProjFromView",r=>r.camera.projectionMatrix),new m("transformWorldFromModelRS",r=>r.transformWorldFromModelRS),new a("transformWorldFromModelTH",r=>r.transformWorldFromModelTH),new a("transformWorldFromModelTL",r=>r.transformWorldFromModelTL)),n.code.add(t`vec3 positionWorldCameraRelative() {
vec3 rotatedModelPosition = transformWorldFromModelRS * position;
vec3 transform_CameraRelativeFromModel = dpAdd(
transformWorldFromModelTL,
transformWorldFromModelTH,
-transformWorldFromViewTL,
-transformWorldFromViewTH
);
return transform_CameraRelativeFromModel + rotatedModelPosition;
}`),n.code.add(t`
    void forwardPosition(float fOffset) {
      vPositionWorldCameraRelative = positionWorldCameraRelative();
      if (fOffset != 0.0) {
        vPositionWorldCameraRelative += fOffset * ${o.spherical?t`normalize(transformWorldFromViewTL + vPositionWorldCameraRelative)`:t`vec3(0.0, 0.0, 1.0)`};
      }

      vPosition_view = transformViewFromCameraRelativeRS * vPositionWorldCameraRelative;
      gl_Position = transformProjFromView * vec4(vPosition_view, 1.0);
    }
  `),v.uniforms.add(new i("transformWorldFromViewTL",r=>r.transformWorldFromViewTL)),n.code.add(t`vec3 positionWorld() {
return transformWorldFromViewTL + vPositionWorldCameraRelative;
}`),v.code.add(t`vec3 positionWorld() {
return transformWorldFromViewTL + vPositionWorldCameraRelative;
}`)}class f extends l{constructor(){super(...arguments),this.transformWorldFromViewTH=o(),this.transformWorldFromViewTL=o(),this.transformViewFromCameraRelativeRS=r()}}class v extends l{constructor(){super(...arguments),this.transformWorldFromModelRS=r(),this.transformWorldFromModelTH=o(),this.transformWorldFromModelTL=o()}}export{n as VertexPosition,v as VertexPositionDrawParameters,f as VertexPositionPassParameters};
