Skip to content

Commit

Permalink
feat: point-light
Browse files Browse the repository at this point in the history
  • Loading branch information
sheepbox8646 committed Sep 16, 2024
1 parent cedf1d6 commit 5863175
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 58 additions & 0 deletions extensions/lights/src/point-light.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<script setup lang="ts">
import { defineWidget } from '@vue-motion/core';
import { WidgetOptions } from '@vue-motion/lib';
export interface PointLightOptions extends WidgetOptions {
constant?: number
exponent?: number
surfaceScale?: number
color: string
x: number
y: number
z: number
type: 'diffuse' | 'specular'
}
const props = defineProps<PointLightOptions>()
const options = defineWidget<PointLightOptions>(props)
const id = Math.random().toString(36).substring(2, 9)
const diffuseId = options.wid || `diffuse-${id}`
const specularId = options.wid || `specular-${id}`
</script>

<template>
<filter :id="diffuseId">
<feDiffuseLighting
:result="diffuseId"
:lighting-color="options.color"
>
<fePointLight
:x="options.x"
:y="options.y"
:z="options.z"
:diffuse-constant="options.type === 'diffuse' ? options.constant : ''"
:diffuse-exponent="options.type === 'diffuse' ? options.exponent : ''"
:surface-scale="options.surfaceScale"
/>
</feDiffuseLighting>
</filter>
<filter :id="specularId">
<feSpecularLighting
:result="specularId"
:lighting-color="options.color"
>
<fePointLight
:x="options.x"
:y="options.y"
:z="options.z"
:specular-constant="options.type === 'specular' ? options.constant : ''"
:specular-exponent="options.type === 'specular' ? options.exponent : ''"
:surface-scale="options.surfaceScale"
/>
</feSpecularLighting>
</filter>
<g :filter="`url(#${options.type === 'diffuse' ? diffuseId : specularId})`">
<slot></slot>
</g>
</template>

0 comments on commit 5863175

Please sign in to comment.